赞
踩
我使用dockerfile-maven插件在我的docker容器和maven-failsafe-plugin中移动jar文件来启动我的集成测试.但maven从未运行集成测试方法.下面是我的pom.xml
org.apache.maven.plugins
maven-surefire-plugin
2.20.1
**/*IntegrationTestIT.java
integration-test
test
integration-test
none
**/*IntegrationTestIT.java
org.apache.maven.plugins
maven-failsafe-plugin
2.12
integration-test
**/*.java
com.spotify
dockerfile-maven-plugin
1.3.7
default
build
push
rohitbarnwal7/presto_log_updated
${project.version}
plugin-${project.version}-jar-with-dependencies.jar
我已将Integration测试类命名为IntegrationTestIT.java,并按照this来集成dockerfile maven插件.
我一直坚持这个问题,任何帮助都将受到高度赞赏.
更新1:
添加我的IntegrationTestIT.java文件.在这里,我尝试连接presto并运行查询以检查它们是否已记录到文件中.(Maven项目是一个presto插件,它可以记录在presto服务器上运行的所有presto查询.)
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.io.IOException;
import java.io.File;
import java.util.Scanner;
// import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import static org.junit.matchers.JUnitMatchers.*;
import io.prestodb.tempto.query.QueryExecutor;
import static io.prestodb.tempto.context.ThreadLocalTestContextHolder.testContext;
import io.prestodb.tempto.AfterTestWithContext;
import io.prestodb.tempto.BeforeTestWithContext;
import org.junit.Assert.*;
import com.facebook.presto.jdbc.PrestoDriver;
import io.airlift.log.Logger;
import org.testng.annotations.*;
class IntegrationTestIT{
@Test
void checkForQueryInFile() {
System.out.println("This test method should be run");
String url = "jdbc:presto://sandbox:8080/jmx/default";
Statement stmt = null;
try {
Connection connection = DriverManager.getConnection(url, "jumbo", null);
stmt = connection.createStatement();
String file_path = "";
String sql_string = "show schemas";
ResultSet rs = stmt.executeQuery(sql_string);
File folder = new File("//jars");
// Move this to constant class
File[] files = folder.listFiles();
for (File file:files) {
if (file.isFile()) {
file_path = file.getAbsolutePath();
}
}
File log_file = new File(file_path);
final String scanner = new Scanner(log_file).useDelimiter("\\Z").next();;
assertThat(scanner, containsString(sql_string));
rs.close();
stmt.close();
connection.close();
} catch (IOException exception) {
exception.printStackTrace();
} catch(SQLException sqlException) {
sqlException.printStackTrace();
}
}
}
更新2:
这是来自控制台的maven测试报告.
[INFO]已成功构建rohitbarnwal7 / presto_log_updated:0.0.1
[INFO] — maven-surefire-plugin:2.20.1:test(integration-test)@plugin
[INFO] T E S T S.
[INFO]运行IntegrationTestIT
[INFO]测试运行:0,失败:0,错误:0,跳过:0,已过去时间:0.804秒 – 在IntegrationTestIT中
[INFO]结果:
[INFO]测试运行:0,失败:0,错误:0,跳过:0
[INFO] — maven-failsafe-plugin:2.12:integration-test(默认)@plugin —
[INFO]故障安全报告目录:/ Users / rohit / workspace / work / presto-plugins / target / failsafe-reports
T E S T S.
运行IntegrationTestIT
配置TestNG:org.apache.maven.surefire.testng.conf.TestNGMapConfigurator@7960847b
测试运行:0,失败:0,错误:0,跳过:0,经过时间:0.469秒
结果:
测试运行:0,失败:0,错误:0,跳过:0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。