Last change
on this file since 899 was 896, checked in by wouter, 6 months ago |
#310 moved GetResourcesTest to junit-t because this test is so much easier if we have junit translator and package translation. junit tests now require @RunWith annotation for proper translation. Added more translators
|
File size:
1.2 KB
|
Line | |
---|
1 | package testcode;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 | import static org.junit.Assert.assertFalse;
|
---|
5 |
|
---|
6 | import org.junit.Test;
|
---|
7 | import org.junit.internal.runners.JUnit4ClassRunner;
|
---|
8 | import org.junit.runner.RunWith;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Test that having a @Test annotation results in the translated class to extend
|
---|
12 | * unittest.TestCase. We can not test this in java, therefore this class is not
|
---|
13 | * runnable.
|
---|
14 | */
|
---|
15 | @RunWith(JUnit4ClassRunner.class)
|
---|
16 | public class SomeUnitTest {
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * NOTE NO CONSTRUCTOR. This is needed to check that the proper constructor,
|
---|
20 | * matching in this case the implicit superclass TestCase from Python, is
|
---|
21 | * created. This is a special case, in normal cases java already enforces
|
---|
22 | * all required code including the call to super().
|
---|
23 | */
|
---|
24 | @Test
|
---|
25 | public void test1() {
|
---|
26 | assertFalse(1 == value());
|
---|
27 | }
|
---|
28 |
|
---|
29 | private int value() {
|
---|
30 | return 2;
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * This test does not have the name testXXX.java and therefore the
|
---|
35 | * translator must introduce a new method that does start with "test"
|
---|
36 | */
|
---|
37 | @Test
|
---|
38 | public void someTest() {
|
---|
39 | assertEquals(2, value());
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Translating this must result in testRaises(). This test must NOT start
|
---|
44 | * with 'test'
|
---|
45 | */
|
---|
46 | @Test(expected = ArithmeticException.class)
|
---|
47 | public void NullTest() {
|
---|
48 | int x = 1 / 0;
|
---|
49 | }
|
---|
50 |
|
---|
51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.