且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用spring boot和testng运行集成测试时出错

更新时间:2022-05-29 22:01:02

看起来配置正确,并且服务器在端口8008上正确运行.我的应用在运行测试用例时给出了拒绝连接错误,未选择正确的端口

looks like configuration is correct and server is runnig proplerly on port 8008.my app was not picking correct port while running test cases giving connection refused error

在基本测试的情况下进行了以下更改,因为testng不需要SpringRunner

following changes were done in basetest case since SpringRunner is not required with testng

 @ContextConfiguration(locations={"classpath:objectModelContext.xml"})
//@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class BaseITCase extends com.test.common.BaseITCase {

    protected static final String baseUrl = "http://localhost:" +  port + "/test/api/";

    protected String getAdminToken(String username, String password, String deviceId) throws Exception {
    }
}