gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 10:15:06 25 4
gpt4 key购买 nike

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

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();
}
}

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

"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

我尝试按照以下方式无效并重新启动: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 的内容:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
classpath:org/springframework/beans/factory/xml/spring-beans-4.2.xsd">
<import resource="classpath*:/entitymanager-test.xml"/>

<!-- <import resource="classpath*:/core-impl-context.xml" />-->
<!--<import resource="classpath*:/configurability-impl-context.xml" />-->

<bean id="portalUserLocationAssociationDao" class="xxx.yyy.zzz.PortalUserLocationAssociationDaoImpl"/>

</beans>

想不出还有什么可以尝试的。

最佳答案

您的上下文配置似乎有问题

尝试更改配置路径,如下所示:"classpath:applicationContext-dao-test.xml"并将该 xml 放置在项目的 root 目录中。

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

关于java - 为什么 IDEA 忽略我的 testng 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51821989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com