java - NoSuchMethodException: main while running TestNG test on Spring application -


i trying write test calling rest api using testng. try run using intellij idea, , following error:

exception in thread "main" java.lang.nosuchmethodexception: test.api.testhospitals.main([ljava.lang.string;) @ java.lang.class.getmethod(class.java:1670) @ com.intellij.rt.execution.application.appmain.main(appmain.java:125)

this test class. what's wrong it? why java need main method in it? lost.

package test.api;  import com.example.backend.entity.postgres.user; import com.example.backend.utils.jsonutils; import com.example.mainserver.service.rest.callbacklocalservice; import org.springframework.beans.factory.annotation.autowired; import org.springframework.test.context.contextconfiguration; import org.springframework.test.context.testng.abstracttestngspringcontexttests; import org.testng.annotations.test; import test.all.loginfabric; import test.all.patientpersonfabric;  @contextconfiguration(locations = {"classpath:spring-test-config.xml"}) public class testhospitals extends abstracttestngspringcontexttests {      @autowired     private callbacklocalservice callbacklocalservice;      public static final string login = "user@example.com";     public static final string pass = "aed2pbd5ae3lci";      @test(enabled = true)     public void testaddpatient() {         loginfabric loginfabric = new loginfabric();         user user = loginfabric.loginuser(login, pass, callbacklocalservice);         patientpersonfabric.patientperson p = patientpersonfabric.generatepatientperson();         string patientjson = jsonutils.getjson(p, true);         system.out.println(patientjson);     } } 

minimal configuration set in spring-test-config.xml:

<?xml version="1.0" encoding="utf-8"?>  <beans xmlns="http://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xmlns:context="http://www.springframework.org/schema/context"        xsi:schemalocation="         http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans.xsd         http://www.springframework.org/schema/context ">     <context:component-scan base-package="com.example.mainserver"/>      <bean id="callbacklocalservice" name="callbacklocalservice"           class="com.example.mainserver.service.rest.callbacklocalservice"/>  </beans> 

i have warning/error mark "main method not found" in idea's run configuration:

main method not found, intellij idea

update solution

as m. deinum explained, problem due disabled testng-j plugin in intellij. enabled , restarted idea, had remove run configuration test. re-run test shift-f10 , ok.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -