Reputation: 103437
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...
Upvotes: 3
Views: 6422
Reputation: 77
if your tests is in Android framework,please add this in your gradle file:
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt'
}
then it's ok.
Upvotes: 2
Reputation: 1351
Use JUnit4TestAdapter
to adapt your test class to new environment in case of migration.
It's useful when you get junit.framework.AssertionFailedError: No tests found
error.
ex: TestSuiteEx
contains all my test case classes like this:
@RunWith(Suite.class)
@SuiteClasses({
SampleTest.class,
myTestCases.class
})
Then I added AllTests
containing the following code:
public static Test suite() {
TestSuite suite = new TestSuite("all tests");
suite.addTest(new JUnit4TestAdapter(TestSuiteEx.class));
return suite;
}
It worked for me perfectly. :)
Happy coding.
Upvotes: 0
Reputation: 8934
Are you calling addTestSuite
suite.addTestSuite(DetailsTest.class)
where you should be calling addTest
suite.addTest(DetailsTest.class)
Upvotes: 2