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

Last change on this file since 1358 was 1323, checked in by wouter, 13 days ago

#407 now also translating @Ignore

File size: 1.6 KB
RevLine 
[717]1package testcode;
2
[730]3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertFalse;
5
[1323]6import org.junit.Ignore;
[717]7import org.junit.Test;
[896]8import org.junit.internal.runners.JUnit4ClassRunner;
9import org.junit.runner.RunWith;
[717]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 */
[896]16@RunWith(JUnit4ClassRunner.class)
[717]17public class SomeUnitTest {
18
[958]19 public SomeUnitTest() {
20 // do nothing. This is just to test that
21 // we can handle the presence of a constructor.
22 }
23
[730]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 */
[717]30 @Test
31 public void test1() {
[730]32 assertFalse(1 == value());
[717]33 }
34
[730]35 private int value() {
36 return 2;
37 }
38
[721]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
[896]44 public void someTest() {
[730]45 assertEquals(2, value());
[721]46 }
47
48 /**
[896]49 * Translating this must result in testRaises(). This test must NOT start
50 * with 'test'
[721]51 */
[730]52 @Test(expected = ArithmeticException.class)
[896]53 public void NullTest() {
[730]54 int x = 1 / 0;
[721]55 }
56
[1323]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
[717]69}
Note: See TracBrowser for help on using the repository browser.