Before testing, you need to import JUnit's two packages, respectively
junit:4.12;hamcrest-core:1.1
1. Basic Test Label
@Test, @Before, @After
2. Group Testing
Sometimes multiple test files, if one goes to execute is certainly a waste of time, then how to do it?
If there are Firtest.java,sectest.java now, there are multiple methods in each test class, how do you want to test this file together?
Create a new Java test file named Grouptest, and then write the code
@RunWith (Suite. Class) @Suite. suiteclasses ({ firtest. class , Sectest. class })publicclass grouptest { // keep empty }
Then right-click to run the class.
3. Ignoring a test method
@Ignore
4, require a method to run the maximum time
@Test (timeout=1000)//unit is MS
Can be found that although the super-times wrong, but still down the implementation of
You can do this if you want to limit all the methods in this test class (note that this 4.10 version is not available)
Java Test Tools use (1)--junit