- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我开始在 Intellij 中使用 selenium 和 TestNG(Java 基础语言)创建一组测试。我能够在 IntelliJ 中编译并运行,但是当我添加 gradle 文件(如下所示)时,我遇到了一些编译路径错误。
Gradle :
apply plugin: 'java'
dependencies {
testCompile(group: 'org.uncommons', name: 'reportng', version: '1.1.4') {
exclude(module: 'testng')
}
testCompile group: 'com.google.inject', name: 'guice', version: '3.0'
compile group: 'xml-apis', name: 'xml-apis', version:'1.4.01'
}
configurations.all {
resolutionStrategy {
force 'xml-apis:xml-apis:1.4.01'
}
}
task testfeature1(type: Test) {
ignoreFailures = true
useTestNG() {
suites 'Resources/Dashboards/feature1_testng.xml'
useDefaultListeners = false
listeners << 'org.uncommons.reportng.HTMLReporter'
listeners << 'org.uncommons.reportng.JUnitXMLReporter'
}
}
终端输出:
13:51:08.287 [DEBUG]
[org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':testfeature1'
13:51:08.301 [INFO] [org.gradle.api.internal.file.collections.DirectoryFileTree] file or directory '/Users/******/Workspace/TestNG_Automation/build/classes/test', not found
13:51:08.301 [INFO] [org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter] Skipping task ':testfeature1' as it has no source files.
我猜测 Intellij 将内容编译到 out 文件夹中,正如我现在看到的那样,但没有构建文件夹。如何更改此设置以使 gradle 和 Intellij 以相同的方式工作?
最佳答案
让我引用我正在从事的另一个示例项目: https://github.com/virenv/ParallelReporter
在我的 build.gradle 的顶部,它的配置如下:
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
然后使用以下命令设置您的项目:
gradle clean idea
如果您将测试输出发送到 /out,那么您可能正在以 TestNG 的身份运行测试,而不是从 Gradle 执行器运行测试。如果你做得正确,Gradle 将生成一个 /build
文件夹,你可以通过如下方式控制测试报告的生成位置:
test {
reports.html.destination = file("$buildDir/reports/gradle")
....
作为“纯 TestNG”运行测试而不是使用 Gradle 执行器的一个优点是 IntelliJ-IDEA 将向您显示有关各个测试成功的更多信息。使用 Gradle 运行时,IntelliJ-IDEA 不够智能,无法向您显示该信息,因此您需要依赖测试报告。
关于java - Gradle 和 TestNG 的 Intellij 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30039144/
我想多次运行一个测试用例。在testng.xml中可以配置吗?如果在测试方法中添加循环,则每次运行的结果将不会受到testng报告的影响。 最佳答案 您不能通过xml来执行此操作,但是可以在@Test
我在 TestNG 中尝试了一些使用硬断言和软断言的示例。虽然软断言按预期工作,但我遇到了硬断言的问题。 根据我从互联网上读到的信息-如果硬断言失败,它不会执行其他测试。 由于 ffPageEleme
我能够在 Eclipse 中完美地运行 testng。但是,我想使用命令行(Win 8)运行它,如不同论坛上所述。以下是我尝试处理错误的不同方法 - 1. java -cp "D:\testng\te
假设我有一个可以并行或串行执行的套件。但是,这样做的决定要留给运行时。启动此套件的常见方法如下: TestNG runner = new TestNG(); if (runInParallel())
如何获得执行TESTNG的方法所花费的时间? sample 测试: @Test(threadPoolSize = 100, invocationCount = 100) public void tes
我发现有一个选项可以通过surefire插件将参数设置为testng xml,然后可以从命令行发送参数。 [...] org.apache.maven.plug
我正在尝试使用这样的命令行运行 testng 测试: C:\Documents and Settings\Administrateur\Bureau\automatic tests testNG>ja
我正在尝试从我的套件文件中删除 testng 参数,因为它们在多个套件中都需要。例如,我有 2 个测试套件,upgrades.xml 和 features.xml。我创建了第三个文件,paramete
目标:并行独立运行 2 个类,其中每个测试将方法名称存储到一个变量中,该变量稍后可以在测试中访问。 问题:当测试并行运行时,它们开始在它们之间共享数据,从而破坏测试。 如果您看到控制台输出这是错误的:
好的,请引用 TestNG doc我可以运行测试 依次 (默认在测试套件中)或在 平行使用 . 现在这是我的 TestNG 配置
我正在尝试从命令行运行TestNG,但这给了我错误。 有人可以告诉我我要去哪里错吗? java -cp C:/TestNG目录/testng-6.2.jar;C:\project目录\src\com\
情况和问题 我有几个测试类,每个类都有几个测试方法。所有测试在后台使用相同的测试数据库。每个测试类初始化其数据库内容,然后在几个测试方法中测试内容。 当我单独运行每个测试时,它们都通过了。但是当我同时
如何让我的 TestNG 报告显示报告中控制台输出的链接?我以前见过 TestNG 这样做,但我现在正在做的一个项目没有显示任何输出,而且我在任何地方都找不到任何说明如何打开它的信息。我尝试在 tes
如果断言失败,如何在 TestNG 中继续执行测试?如何在 TestNG 的 HTML 报告中报告失败? 当我运行以下代码时,执行了断言之后的行,但在报告中未列出断言失败: @Test public
如果断言失败,如何在 TestNG 中继续执行测试?如何在 TestNG 的 HTML 报告中报告失败? 当我运行以下代码时,执行了断言之后的行,但在报告中未列出断言失败: @Test public
我在每个 wiki 使用 TestNG + ReportNG instructions在 gradle 中(我固定在食谱上,因为默认示例对我不起作用)。 我想以某种方式在 TestNG 中捕获控制台输
如何使用 TestNG 自动化功能测试,跨越多个 Java 进程? 我对尝试使用 TestNG 而不是 JUnit 产生了兴趣,因为它声称不仅仅是为单元测试而设计的,但我还没有找到具体的例子来说明如何
如何在测试用例的运行时获取当前正在运行的套件名称?我正在使用下面显示的代码来获取当前套件名称。 监听类: public class SuiteListener implements ISuiteLis
我正在使用 Selenium Webdriver 和 Java 设计一个用于测试的定制自动化框架。 现在出于报告的目的,我正在尝试将 TestNG 框架与我的项目集成。 现在我有一个基于 GUI 的界
出于某种原因,我必须使用旧的 TestNG 库,它没有 "getCurrentXmlTest()).getAllParameters()" API 我应该如何使用testng-5.4-jdk15.ja
我是一名优秀的程序员,十分优秀!