source: java2python/junit-t/someunittest/testcode/SomeUnitTest.java@ 1380

Last change on this file since 1380 was 1323, checked in by wouter, 7 weeks ago

#407 now also translating @Ignore

File size: 1.6 KB
Line 
1package testcode;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertFalse;
5
6import org.junit.Ignore;
7import org.junit.Test;
8import org.junit.internal.runners.JUnit4ClassRunner;
9import org.junit.runner.RunWith;
10
11/**
12 * Test that having a @Test annotation results in the translated class to extend
13 * unittest.TestCase. We can not test this in java, therefore this class is not
14 * runnable.
15 */
16@RunWith(JUnit4ClassRunner.class)
17public class SomeUnitTest {
18
19 public SomeUnitTest() {
20 // do nothing. This is just to test that
21 // we can handle the presence of a constructor.
22 }
23
24 /**
25 * NOTE NO CONSTRUCTOR. This is needed to check that the proper constructor,
26 * matching in this case the implicit superclass TestCase from Python, is
27 * created. This is a special case, in normal cases java already enforces
28 * all required code including the call to super().
29 */
30 @Test
31 public void test1() {
32 assertFalse(1 == value());
33 }
34
35 private int value() {
36 return 2;
37 }
38
39 /**
40 * This test does not have the name testXXX.java and therefore the
41 * translator must introduce a new method that does start with "test"
42 */
43 @Test
44 public void someTest() {
45 assertEquals(2, value());
46 }
47
48 /**
49 * Translating this must result in testRaises(). This test must NOT start
50 * with 'test'
51 */
52 @Test(expected = ArithmeticException.class)
53 public void NullTest() {
54 int x = 1 / 0;
55 }
56
57 @Test
58 @Ignore
59 public void failingTest1() {
60 throw new IllegalStateException("This test always fails");
61 }
62
63 @Ignore
64 @Test
65 public void failingTest21() {
66 throw new IllegalStateException("This test always fails");
67 }
68
69}
Note: See TracBrowser for help on using the repository browser.