- This project is build just to test the working of the junit3 with the java project
- first create a project using maven choosing archtetype to be quickstart
- Second Create a class in the project with some data in our case it is out Dog with getters and setters
- now click on the default package and create the jnuit test cases
- Above option will automatically create the class
- we just have to add the test cases to our class
- @BeforeClass --> will run before any test case will run --> its name should be before
- @AfterClass --> will run at the last of the test cases --> Its name should be after
- @Before --> will run before every test cases --> Its name should be setUp
- @After --> will run after every test cases --> Its name should be tearDown
- @Test --> is used to create a test case --> just put this above any of the function
-
Add the annotaion @Test above any funciton with void return type
-
In this function we will compare some values using assert.Equals like there are other methods that can be used.
assertEquals("Error name is different","tommy",mdogName);
-
full example of the test case is
public void myDogBreedTest() {
String breed=myDog.getBreed();
assertEquals("Breed not same","bernard",breed);
}