Lahiru Chandima
Lahiru Chandima

Reputation: 24068

Android Tests does not recognize my test method

I am trying to add some unit tests to my android app. Following is what I tried.

Created a directory for my tests and created a package for test classes inside it.

Created following test class in added package

public class MyFirstTest extends TestCase {

        @Override
        protected void setUp() throws Exception {
            super.setUp();
        }

        @SmallTest
        public void basicTest() {
            assertEquals("abc", "abc");
        }

        @Override
        protected void tearDown() throws Exception {
            super.tearDown();
        }
    }

Created a new Android Tests build configuration in Android Studio

Specified module in build configuration settings and choose to run test cases of my test class (specified class name MyFirstTest in build configuration settings)

But, when I run my build configuration, it says that no tests were found in MyFirstTest class.

junit.framework.AssertionFailedError: No tests found in my.package.tests.MyFirstTest

What should I do to make basicTest() method to get identified as a test case?

Upvotes: 1

Views: 233

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69198

You must name your tests testSomething(), that is starting with test

Upvotes: 1

Related Questions