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 |
|
---|
8 | /**
|
---|
9 | * Test that having a @Test annotation results in the translated class to extend
|
---|
10 | * unittest.TestCase. We can not test this in java, therefore this class is not
|
---|
11 | * runnable.
|
---|
12 | */
|
---|
13 | public class SomeUnitTest {
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * NOTE NO CONSTRUCTOR. This is needed to check that the proper constructor,
|
---|
17 | * matching in this case the implicit superclass TestCase from Python, is
|
---|
18 | * created. This is a special case, in normal cases java already enforces
|
---|
19 | * all required code including the call to super().
|
---|
20 | */
|
---|
21 | @Test
|
---|
22 | public void test1() {
|
---|
23 | assertFalse(1 == value());
|
---|
24 | }
|
---|
25 |
|
---|
26 | private int value() {
|
---|
27 | return 2;
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * This test does not have the name testXXX.java and therefore the
|
---|
32 | * translator must introduce a new method that does start with "test"
|
---|
33 | */
|
---|
34 | @Test
|
---|
35 | public void someothertest() {
|
---|
36 | assertEquals(2, value());
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Translating this must result in testRaises()
|
---|
41 | */
|
---|
42 | @Test(expected = ArithmeticException.class)
|
---|
43 | public void nullTest() {
|
---|
44 | int x = 1 / 0;
|
---|
45 | }
|
---|
46 |
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.