1. Best practices for using JUnit:
1)
Create a new source folder named Test that holds the source code for the testing class
2)
The target class should be under the same package as the test class, so you don't have to import the source code in the test class
In the package, because they are located under the same package
3)
Test class naming rules: If the target class is Calculator, then the test class should be named
Testcalculator, or Calculatortest.
2.Junit slogan: Keep the bar green to keep the code clean.
3.Junit: Unit tests are not meant to prove that you are right, but to prove that you have no errors.
4. Test Cases (TestCase) are a very important aspect of unit testing.
5. Unit testing is primarily used to determine whether the execution of the program is consistent with the results you expect.
6. The test class must inherit from the TestCase parent class
7. in junit 3.8 , the test method needs to meet the following principles:
1 ) . Public of the
2 ) . void of the
3 ) . No method parameters
4 ) . the method name must be Test Start
The 8.Test case must remain completely independent and not allow any dependencies.
9. We cannot rely on the order in which the test methods are executed.
10.DRY (Don ' t Repeat yourself).
The order of execution of the setUp and tearDown methods:
1 )
SetUp
2 )
Testadd
3 )
Teardown
12. Test Runner
Junit.awtui.TestRunner.run (Calculatortest.class);
Junit.textui.TestRunner.run (Calculatortest.class);
Junit.awtui.TestRunner.run ( class name of the test . Class)
graphical Test interface appears .
Junit.textui.TestRunner.run ( class name of the test . Class)
The console interface appears ... ..
Java Learning Chapter (IV)---on JUnit 3.8