为什么IDEA会忽略我的testng测试?

时间:2018-08-13 12:05:49

标签: java spring intellij-idea testng

我写了一个Test NG测试来测试DAO中的查询。当然,作为spring框架的一部分,有一些复杂的设置,但是,目前,测试中没有任何内容。在这里:

read()

这是父类,它只是进行设置:

public class PortalUserLocationAssociationDaoImplTest extends BaseDaoTest {

    @BeforeMethod
    public void setUp() {
    }


    @Test
    public void testGetLocationIds() {
        assertTrue(true);
    }
}

运行它时,我得到以下结果:

@ContextConfiguration(locations = {"/applicationContext-dao-test.xml"})
@TransactionConfiguration(transactionManager = "jpaTransactionManager")
@Transactional
@TestExecutionListeners( { TransactionalTestExecutionListener.class })
public abstract class BaseDaoTest extends AbstractTestNGSpringContextTests {

    public BaseDaoTest() {
        super();
    }
}

我试图使无效,并按照Intellij seems to be ignoring my JUnit tests in a Scala project

重新启动

然后我从以下位置添加了日志请求:https://groups.google.com/a/illuminatedcloud.com/forum/#!topic/discussion/tzWsYki9NBU,但没有添加任何内容。

之前,当我遇到这个问题时,是因为某些东西将我的src / test / java目录翻转为不是单元测试目录,但是这里不是这种情况。我尝试取消标记,然后重新标记它只是为了看看是否有损坏。

我的XML文件在这里:

enter image description here

applicationContext-dao-test.xml的内容:

"C:\Program Files\Java\jdk1.8.0_112\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:65138,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\thehl\.IntelliJIdea2018.1\system\captureAgent\debugger-agent.jar=file:/C:/Users/thehl/AppData/Local/Temp/capture.props -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\plugins\testng\lib\testng-plugin.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_112\jre\lib\rt.jar;C:\casenet\Sources\trucare\libs\com\casenet\trucare\lite-model\target\test-classes;C:\casenet\Sources\trucare\libs\com\casenet\trucare\lite-model\target\classes;C:\casenet\Sources\trucare\libs\com\casenet\trucare\core\casenet-domain-model\target\classes;C:\m2repo\com\casenet\tools\casenet-annotation-processing\1.0\casenet-annotation-processing-1.0.jar;C:\casenet\Sources\trucare\libs\com\casenet\eventing\eventing-api\target\classes;C:\m2repo\com\fasterxml\jackson\core\jackson-annotations\2.9.4\jackson-annotations-2.9.4.jar;C:\m2repo\org\springframework\spring-tx\4.2.2.RELEASE\spring-tx-4.2.2.RELEASE.jar;C:\m2repo\joda-time\joda-time\2.7\joda-time-2.7.jar;C:\m2repo\org\joda\joda-convert\1.5\joda-convert-1.5.jar;C:\m2repo\org\jadira\usertype\usertype.core\3.1.0.CN10\usertype.core-3.1.0.CN10.jar;C:\m2repo\org\jadira\usertype\usertype.spi\3.1.0.CR10\usertype.spi-3.1.0.CR10.jar;C:\m2repo\org\graniteds\granite-core\3.0.0.M2\granite-core-3.0.0.M2.jar;C:\m2repo\org\jbpm\jbpm3\jbpm-jpdl\3.3.1.CN\jbpm-jpdl-3.3.1.CN.jar;C:\m2repo\cglib\cglib\2.1_3\cglib-2.1_3.jar;C:\m2repo\asm\asm\1.5.3\asm-1.5.3.jar;C:\m2repo\bsh\bsh\1.3.0\bsh-1.3.0.jar;C:\m2repo\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\m2repo\junit\junit\4.8.1\junit-4.8.1.jar;C:\m2repo\org\apache\ant\ant\1.7.0\ant-1.7.0.jar;C:\m2repo\org\apache\ant\ant-launcher\1.7.0\ant-launcher-1.7.0.jar;C:\m2repo\org\apache\jackrabbit\jackrabbit-core\1.4.5\jackrabbit-core-1.4.5.jar;C:\m2repo\concurrent\concurrent\1.3.4\concurrent-1.3.4.jar;C:\m2repo\org\apache\jackrabbit\jackrabbit-api\1.4\jackrabbit-api-1.4.jar;C:\m2repo\org\apache\jackrabbit\jackrabbit-jcr-commons\1.4\jackrabbit-jcr-commons-1.4.jar;C:\m2repo\org\apache\jackrabbit\jackrabbit-spi-commons\1.4\jackrabbit-spi-commons-1.4.jar;C:\m2repo\org\apache\jackrabbit\jackrabbit-spi\1.4\jackrabbit-spi-1.4.jar;C:\m2repo\org\apache\jackrabbit\jackrabbit-text-extractors\1.4\jackrabbit-text-extractors-1.4.jar;C:\m2repo\poi\poi\2.5.1-final-20040804\poi-2.5.1-final-20040804.jar;C:\m2repo\pdfbox\pdfbox\0.6.4\pdfbox-0.6.4.jar;C:\m2repo\org\textmining\tm-extractors\0.4\tm-extractors-0.4.jar;C:\m2repo\nekohtml\nekohtml\0.9.4\nekohtml-0.9.4.jar;C:\m2repo\xerces\xercesImpl\2.8.1\xercesImpl-2.8.1.jar;C:\m2repo\org\apache\lucene\lucene-core\2.2.0\lucene-core-2.2.0.jar;C:\m2repo\org\apache\derby\derby\10.2.1.6\derby-10.2.1.6.jar;C:\m2repo\org\javassist\javassist\3.21.0-GA\javassist-3.21.0-GA.jar;C:\m2repo\org\hibernate\hibernate-validator\4.2.0.Final\hibernate-validator-4.2.0.Final.jar;C:\m2repo\javax\validation\validation-api\1.0.0.GA\validation-api-1.0.0.GA.jar;C:\casenet\Sources\trucare\libs\com\casenet\framework\test\casenet-bean-unit\target\classes;C:\m2repo\commons-collections\commons-collections\3.1\commons-collections-3.1.jar;C:\casenet\Sources\trucare\libs\com\casenet\persistence\casenet-persistence-common\target\classes;C:\m2repo\org\hibernate\hibernate-core\4.1.6.Final\hibernate-core-4.1.6.Final.jar;C:\m2repo\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\m2repo\org\jboss\logging\jboss-logging\3.1.3.GA\jboss-logging-3.1.3.GA.jar;C:\m2repo\org\jboss\spec\javax\transaction\jboss-transaction-api_1.1_spec\1.0.0.Final\jboss-transaction-api_1.1_spec-1.0.0.Final.jar;C:\m2repo\org\hibernate\common\hibernate-commons-annotations\4.0.1.Final\hibernate-commons-annotations-4.0.1.Final.jar;C:\m2repo\org\hibernate\hibernate-entitymanager\4.1.6.Final\hibernate-entitymanager-4.1.6.Final.jar;C:\m2repo\org\testng\testng\6.1.1\testng-6.1.1.jar;C:\m2repo\org\beanshell\bsh\2.0b4\bsh-2.0b4.jar;C:\m2repo\com\beust\jcommander\1.12\jcommander-1.12.jar;C:\m2repo\org\yaml\snakeyaml\1.6\snakeyaml-1.6.jar;C:\m2repo\Aspose\Words.jdk16\15.5.0\Words.jdk16-15.5.0.jar;C:\m2repo\Aspose\casenet-Aspose.Words.lic\15.5.0\casenet-Aspose.Words.lic-15.5.0.jar;C:\casenet\Sources\trucare\libs\com\casenet\common\lang\casenet-common-lang\target\classes;C:\m2repo\com\google\guava\guava\17.0\guava-17.0.jar;C:\m2repo\org\springframework\spring-expression\4.2.2.RELEASE\spring-expression-4.2.2.RELEASE.jar;C:\m2repo\log4j\log4j\1.2.16\log4j-1.2.16.jar;C:\m2repo\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;C:\m2repo\org\slf4j\slf4j-log4j12\1.7.7\slf4j-log4j12-1.7.7.jar;C:\m2repo\findbugs\annotations\1.0.0\annotations-1.0.0.jar;C:\m2repo\commons-lang\commons-lang\2.4\commons-lang-2.4.jar;C:\m2repo\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\m2repo\com\lowagie\itext\2.1.0\itext-2.1.0.jar;C:\m2repo\bouncycastle\bcmail-jdk14\136\bcmail-jdk14-136.jar;C:\m2repo\bouncycastle\bcprov-jdk14\136\bcprov-jdk14-136.jar;C:\m2repo\org\springframework\spring-core\4.2.2.RELEASE\spring-core-4.2.2.RELEASE.jar;C:\m2repo\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;C:\m2repo\org\springframework\spring-context\4.2.2.RELEASE\spring-context-4.2.2.RELEASE.jar;C:\m2repo\org\springframework\spring-aop\4.2.2.RELEASE\spring-aop-4.2.2.RELEASE.jar;C:\m2repo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\m2repo\org\springframework\spring-beans\4.2.2.RELEASE\spring-beans-4.2.2.RELEASE.jar;C:\m2repo\org\hibernate\javax\persistence\hibernate-jpa-2.0-api\1.0.1.Final\hibernate-jpa-2.0-api-1.0.1.Final.jar;C:\m2repo\org\springframework\spring-test\4.2.2.RELEASE\spring-test-4.2.2.RELEASE.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2018.1\plugins\testng\lib\jcommander.jar" org.testng.RemoteTestNGStarter -usedefaultlisteners false -socket65137 @w@C:\Users\thehl\AppData\Local\Temp\idea_working_dirs_testng.tmp -temp C:\Users\thehl\AppData\Local\Temp\idea_testng.tmp
Connected to the target VM, address: '127.0.0.1:65138', transport: 'socket'
log4j:WARN No appenders could be found for logger (org.springframework.test.context.BootstrapUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[TestNG] Running:
  C:\Users\thehl\.IntelliJIdea2018.1\system\temp-testng-customsuite.xml

Test ignored.
Disconnected from the target VM, address: '127.0.0.1:65138', transport: 'socket'

===============================================
Default Suite
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 2
===============================================


Process finished with exit code 0

想不出要尝试的其他方式。

1 个答案:

答案 0 :(得分:0)

似乎您在上下文配置

上遇到了问题

尝试像这样更改配置路径:$ composer require sensio/framework-extra-bundle 并将该xml放在项目的 root 目录中。

请参阅:https://www.mkyong.com/unittest/testng-spring-integration-example/