Hi All,
my code is
import junit.framework.TestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
public class Test extends TestCase{
@BeforeClass
public void set() {
System.out.println("in set");
}
@AfterClass
public void af() {
System.out.println("in after");
}
@org.junit.Test
public void temp () {
System.out.println("in testtemp");
}
}
the error
"junit.framework.AssertionFailedError: No tests found in Test"
How to resolve this problem
Thanks in advance
Regards
Pavan
the same staff,
the same staff,
put test before every method. That is,
public void set() { // old
public void testset() { // new
public void af() { // old
public void testaf() { // new
public void temp () { // old
public void temp () { // new
Now it will work
-----------------------
Manaliseepi
How to config JUnit 4
If you are running in Eclipse check the Run configuration for this class it is probably set to Junit3
You're mixing some features of Junit 3.8 and 4.0
@BeforeClass, @AfterClass, @Test are annotations used in Junit 4.0. If you're writing tests with annotations, you do not need to extend TestCase. In addition, the methods for @BeforeClass and @AfterClass should be static.
Annotations feature JUnit4.4
put test before every method. That is,
public void set() { //old
public void testset() { //new
public void af() { //old
public void testaf() { //new
public void temp () { //old
public void testtemp () { //new
the error"junit.framework.AssertionFailedError: No tests found
put test before every method. That is,
public void set() { // old
public void testset() { // new
public void af() { // old
public void testaf() { // new
public void temp () { // old
public void temp () { // new
Now it will work
Regards...
Narain
@Annotation is used with
@Annotation is used with JUnit4 and if u wanna use annotations, u will have to remove "extends TestCase" since its used in JUnit3.
No need to subclass TestCase
Your unit tests needed to extend TestCase in JUnit 3, but in JUnit 4, this is no longer the case. Your TestRunner probably thinks you're trying to run a JUnit 3 test, and is thus looking for methods that start with "test". Your example code only has one test, called "temp()" which will not be seen as a test by JUnit 3 TestRunners.
Simply remove the "extends TestCase" from your code and it should work.
Annotations feature JUnit4.4
Two things
1) @BeforeClass, @AfterClass annotated methods should be static. So, make set, af methods static
2) Since you're using Annotations with Junit4, you are class need not extend TestCase now
Best,
Anand V
Thanks!
That was it!
Thanks!
-----------------------------
best Film