Created
March 28, 2015 11:37
-
-
Save miguelpardal/1164220fabfb647b47a2 to your computer and use it in GitHub Desktop.
JUnit 4 example test class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example.test; | |
import org.junit.*; | |
import static org.junit.Assert.*; | |
/** | |
* Test suite | |
*/ | |
public class ExampleTest { | |
// static members | |
// one-time initialization and clean-up | |
@BeforeClass | |
public static void oneTimeSetUp() { | |
} | |
@AfterClass | |
public static void oneTimeTearDown() { | |
} | |
// members | |
// initialization and clean-up for each test | |
@Before | |
public void setUp() { | |
} | |
@After | |
public void tearDown() { | |
} | |
// tests | |
@Test | |
public void test() { | |
// assertEquals(expected, actual); | |
// if the assert fails, the test fails | |
} | |
@Test(expected=ExampleException.class) | |
public void testException() throws Exception { | |
// JUnit expects the exception declared in the annotation | |
// if it is not thrown, the test fails | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment