Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

junit AssertionFailedError

 
Nidhi Singhal
Ranch Hand
Posts: 89
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I get the following error whenever I run a test case:

junit.framework.AssertionFailedError: No tests found in <path of test class>

I am using JUnit 4 for testing. The class contains tests methods denoted by @Test.

I am unable to understand as to why I am getting the above error.

-Nidhi
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is your other problem at http://www.coderanch.com/t/108617/tools/JUnit-error resolved?

*How* to you try to run the tests? Are you using the string "<path of test class>" somewhere? You will probably need to replace that string with, well, the actual path of the test class...
 
Nidhi Singhal
Ranch Hand
Posts: 89
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

My last problem has got resolved. It was a compile time error as it was unable to find a jar file.

In the below error statement:
junit.framework.AssertionFailedError: No tests found in <path of test class>

By string <path of test class> I mean to say that the error shows the path of the test class here.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see.

Can you show us the code of the testcase class, please?
 
Armando Cervantes
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there,

Was your problem resolved? I am having the same issue and the test code I am running came straight from the JUnit FAQ page:

package junitfaq;

import org.junit.*;
import static org.junit.Assert.*;
import java.util.*;

public class UtilTest {

private Collection<Object> collection;

@Before
public void setUp() {
collection = new ArrayList<Object>();
}

@Test
public void testEmptyCollection() {
assertTrue(collection.isEmpty());
}

/*
@Test
public void testOneItemCollection() {
collection.add("itemA");
assertEquals(1, collection.size());
}
*/
}

If you can share your solution that would be great!

Thanks,
Armando
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same question: How are you trying to run the test?

My first guess would be that your test runner is expecting a JUnit 3 testcase.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic