Saturday 23 October 2021

How to create junit test case in Eclipse?

Right click on the Java class -> New -> Other...

 

 


Search for the string test.




Select the option ‘Junit Test Case’ and click on Next button.

 


 

Select the library (junit3, 4 or Jupiter) of your choice and click on Next button.

 

 


Select methods for which test method stubs should be created. For example, I selected sun method here. Click on Finish button.

 

You can see ‘ArithmeticTest.java’ file is created with below content in src/test/java folder.

package com.sample.app;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

class ArithmeticTest {

	@Test
	void testSum() {
		fail("Not yet implemented");
	}

}

 

 



Previous                                                    Next                                                    Home

No comments:

Post a Comment