Rev | Line | |
---|
[717] | 1 | package testcode;
|
---|
| 2 |
|
---|
[730] | 3 | import static org.junit.Assert.assertEquals;
|
---|
| 4 | import static org.junit.Assert.assertFalse;
|
---|
| 5 |
|
---|
[717] | 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 |
|
---|
[730] | 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 | */
|
---|
[717] | 21 | @Test
|
---|
| 22 | public void test1() {
|
---|
[730] | 23 | assertFalse(1 == value());
|
---|
[717] | 24 | }
|
---|
| 25 |
|
---|
[730] | 26 | private int value() {
|
---|
| 27 | return 2;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
[721] | 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() {
|
---|
[730] | 36 | assertEquals(2, value());
|
---|
[721] | 37 | }
|
---|
| 38 |
|
---|
| 39 | /**
|
---|
| 40 | * Translating this must result in testRaises()
|
---|
| 41 | */
|
---|
[730] | 42 | @Test(expected = ArithmeticException.class)
|
---|
[721] | 43 | public void nullTest() {
|
---|
[730] | 44 | int x = 1 / 0;
|
---|
[721] | 45 | }
|
---|
| 46 |
|
---|
[717] | 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.