package testcode; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import org.junit.Test; /** * Test that having a @Test annotation results in the translated class to extend * unittest.TestCase. We can not test this in java, therefore this class is not * runnable. */ public class SomeUnitTest { /** * NOTE NO CONSTRUCTOR. This is needed to check that the proper constructor, * matching in this case the implicit superclass TestCase from Python, is * created. This is a special case, in normal cases java already enforces * all required code including the call to super(). */ @Test public void test1() { assertFalse(1 == value()); } private int value() { return 2; } /** * This test does not have the name testXXX.java and therefore the * translator must introduce a new method that does start with "test" */ @Test public void someothertest() { assertEquals(2, value()); } /** * Translating this must result in testRaises() */ @Test(expected = ArithmeticException.class) public void nullTest() { int x = 1 / 0; } }