Rachel Rachel - 7 months ago 21
Java Question

JUnit : AssertionFailedError, tests not found in

Here is my

testMethod
in question,

public class DetailsTest extends TestCase
{
public void testGetQuotes() throws Exception
{
int bookSize = getBookSize();
List<Details> detailList = getDetailLists();
assertNotNull(bookSize);
assertEquals(bookSize, detailList.size());
assertNotNull(detailList.size());
}
}


My class extends
JUnit : TestCase
, not sure what is wrong in here that is causing the issue...am using
junit 3.8.1


Update
I have gone through similar questions on SO but it has not been very helpful.

Update 2 : StackTrace

1) warning(junit.framework.TestSuite$1)junit.framework.AssertionFailedError: No tests found in com.comp.Details.DetailsTest
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
at junit.extensions.TestSetup.run(TestSetup.java:23)


FAILURES!!!
Tests run: 1, Failures: 1, Errors: 0

Update 3: I just had Details class in my testSuite and not DetailsTest, fixed it and now it works fine...one of those days...you see...

Answer

Are you calling addTestSuite

suite.addTestSuite(DetailsTest.class)

where you should be calling addTest

suite.addTest(DetailsTest.class)