I need to solve a java problem for an interview, and they have sent me the test class. It starts with
import org.junit.Before;
and also ha
In starting code line copy past 'Junit' or 'TestNG' elements will show with Error till you import library with the Project File.
To import Libraries in to project:
Right Click on the Project --> Properties --> Java Build Path --> Libraries -> Add Library -> 'Junit' or 'TestNG'
If you use maven and this piece of code is located in the main
folder, try relocating it to the test
folder.
When you add TestNG to your Maven dependencies , Change scope from test to compile.Hope this would solve your issue..
Seem to Junit jar file is not in path also make sure you are using jdk1.5 or above.
you need to add Junit dependency in pom.xml file, it means you need to update with latest version.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
If using Maven you can context click and run 'Maven/Update Project...'