部署战争中的测试

时间:2017-10-07 05:15:54

标签: java spring testing deployment

测试没有开始。当我尝试使用嵌入式Tomcat时 - 一切都很好。

当我将测试部署到Wildfly时 - 我遇到了错误: "由以下原因引起:org.springframework.context.ApplicationContextException:由于缺少EmbeddedServletContainerFactory bean而无法启动EmbeddedWebApplicationContext。"

服务器日志和源代码: https://github.com/cheryuriy/books/tree/master/src/main/java/server

测试在"单位"包。测试注释:

@TestPropertySource("/application-unit.properties")
@SpringBootTest(classes = Start.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Transactional
@DirtiesContext
public class Tests extends AbstractTestNGSpringContextTests
{...

我通过LoadTest类加载测试:

@Profile("unit")
@Component
public class LoadTest {
    @PostConstruct
    public void Start()throws Exception{
            XmlSuite suite = new XmlSuite();
            suite.setName("TmpSuite");
            XmlTest test = new XmlTest(suite);
            test.setName("TmpTest");
            List<XmlClass> classes = new ArrayList<XmlClass>();
            classes.add(new XmlClass("server.unit.Tests"));
            test.setXmlClasses(classes);
            List<XmlSuite> suites = new ArrayList<XmlSuite>();
            suites.add(suite);
            TestNG tng = new TestNG();
            tng.setXmlSuites(suites);
            tng.run();
}}

测试结果:

=============================================== 2017-10-01 10:58:09,964 INFO [stdout](ServerService线程池 - 69)TmpSuite 2017-10-01 10:58:09,964 INFO [stdout](ServerService线程池 - 69)总测试运行:5,失败:0,跳过:5 2017-10-01 10:58:09,964 INFO [stdout](ServerService线程池 - 69)配置失败:1 ,跳过:0 2017-10-01 10:58:09,980 INFO [stdout](ServerService Thread Pool - 69)============================ ===================

感谢您的帮助。

0 个答案:

没有答案