java - 带有Gradle和TestNG的FarmIntegrationTest无法运行?

标签 java gradle testng gretty

我正在尝试使用gretty farmIntegrationTest调用TestNG的测试套件设置。但是测试无法运行。

服务器场启动,然后干净退出,没有迹象表明甚至尝试了测试。

以下是Gradle片段以供查看:

Gretty的配置:

gretty {
    integrationTestTask = 'firefoxTest'
    httpPort = 8080;
    servletContainer = 'tomcat8'
    extraResourceBase 'build/gwt/out'
    jvmArgs = ['-Dfile.encoding=UTF-8', '-Xmx6144M']
}

测试任务配置:
task firefoxTest(type: Test)  {
  useTestNG()
  maxHeapSize = "512m"
}

这是我的入门测试课:
package selenium.test;

import java.io.File;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class Farm {
    private WebDriver driver=null;
    @BeforeSuite
    public void init() {
        System.setProperty("webdriver.gecko.driver", new File("drivers/linux-x64/geckodriver").getAbsolutePath());
        driver = new FirefoxDriver();
    }
    @AfterSuite
    public void teardown() {
        if (driver!=null) {
            driver.close();
        }
    }
    @Test
    public void isFarmAlive() throws InterruptedException {
            driver.navigate().to("http://localhost:8080/RestyGwtCodecTester/");
            Thread.sleep(10000);
    }
}

输出:
michael@michael-desktop:~/git/RestyGwtCodecTester/RestyGwtCodecTester$ gradle farmintegrationtest
Parallel execution is an incubating feature.

> Configure project :
Gradle now uses separate output directories for each JVM language, but this build assumes a single directory for all classes from a source set. This behaviour has been deprecated and is scheduled to be removed in Gradle 5.0
        at build_9lyawgow85f0zt9zngx2sy6wt$_run_closure3.doCall(/home/michael/git/RestyGwtCodecTester/RestyGwtCodecTester/build.gradle:51)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

Oct 10, 2017 10:48:13 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Oct 10, 2017 10:48:13 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Oct 10, 2017 10:48:13 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Oct 10, 2017 10:48:13 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.44
Oct 10, 2017 10:48:13 AM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
Oct 10, 2017 10:48:14 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Oct 10, 2017 10:48:14 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
10:48:14 INFO  Tomcat 8.0.44 started and listening on port 8080
10:48:14 INFO  RestyGwtCodecTester runs at:
10:48:14 INFO    http://localhost:8080/RestyGwtCodecTester
Oct 10, 2017 10:48:14 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-8080"]
Oct 10, 2017 10:48:14 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Tomcat
Oct 10, 2017 10:48:14 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-nio-8080"]
Oct 10, 2017 10:48:14 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-nio-8080"]

> Task :farmAfterIntegrationTest
Server stopped.


BUILD SUCCESSFUL in 4s
12 actionable tasks: 2 executed, 10 up-to-date
michael@michael-desktop:~/git/RestyGwtCodecTester/RestyGwtCodecTester$ 

最佳答案

好的,因此当我指定farmintegrationtest值并且正确的命令是:时,似乎测试任务已“扩展”

gradle firefoxTest

并不是
gradle farmIntegrationTest

从文档来看,这对我来说并不明显。

如果服务器场启动和停止,无论如何将测试标记为“最新”,它也会跳过测试,这增加了我的困惑。

我已将测试任务的配置调整为以下内容:
task firefoxTest(type: Test)  {
  useTestNG()
  dependsOn 'cleanTest'
  maxHeapSize = "512m"
}

这样,测试套件将在每次调用时运行,而无需考虑先前的成功或失败。

关于java - 带有Gradle和TestNG的FarmIntegrationTest无法运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46669593/

相关文章:

Gradle multiproject 在项目上给出 "Could not find property ' sourceSets' 错误

android - 除非在 Android Studio 中打开,否则 Gradle 不会选择 Android 构建工具

java - 在 AIX 上运行 JUnit 或 testng TC

java - 在测试方法中重新加载或刷新 Spring 应用程序上下文?

java - ConcurrentHashMap 线程内的 Treemap 是否安全?

Java:带有 Callables 的 ExecutorService:在循环中重用同一个池?需要关机吗?

java - Spring boot Gradle 不生成包装器并且不生成可运行的 jar

java - 如何运行 2 个不同的游戏!同一台本地机器上两个不同端口的框架实例?

java - Android java.lang.UnsatisfiedLinkError 与 native 库

java - 混合 Hamcrest 和 TestNG