1

I am writing integration tests with TestNG and facing this trivial issue.

No runnable methods
     java.lang.Exception: No runnable methods
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

Test class is like this (After Stephen's suggestion, I removed SpringJunitRunner):

@Test
@ContextConfiguration(locations = { "file:spring-configuration/mobiusdatabase-integration-testing.xml" })
public class PersistUrlTests extends AbstractTestNGSpringContextTests {

        @Autowired
        protected MobiusDatabaseServiceClient mobiusDatabaseServiceClient;

        @Autowired
        UrlDAO urlDAO;

        @Autowired
        ScraperUrlDAO scraperUrlDAO;

        @BeforeClass
        public static void init() throws Exception {

        }

        @Test
        public void checkTest() {
            GetActiveCategoriesResponse response = mobiusDatabaseServiceClient.newGetActiveCategoriesCall().call();
            System.out.println(response.getCategoryList());
            Assert.assertTrue(true);
        }
}

This error usually occurs when we don't have @Test annotation or if we don't have @Runner. Do we need some other set-up for TestNG?

instanceOfObject
  • 2,936
  • 5
  • 49
  • 85

1 Answers1

2

You are trying to use SpringJUnit4ClassRunner to run a TestNG unit test. That won't work. A JUnit runner expects to find test classes designated by a different @Test annotation.

I don't know what the correct solution is though, because there isn't a SpringTestNGClassRunner class in the obvious package.

UPDATE - here's the explanation!

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216