当前位置: 首页 > 知识库问答 >
问题:

如何按分级测试任务执行测试方法?

易瀚漠
2023-03-14

当我运行testing.xml时,testNG适合于它的运行,但当运行gradle测试任务时,它不执行测试

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite guice-stage="DEVELOPMENT" name="Default suite">
  <test verbose="2" name="test">
    <classes>
      <class name="com.example.EmpBusinessLogicTest"/>
    </classes>
  </test> <!-- Default test -->
</suite> <!-- Default suite -->

buildscript{ext{springBootVersion='1.4.1.release'}存储库{mavenCentral()}依赖项{classpath(“org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}”)}}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
  baseName = 'demo'
  version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8


repositories {
  mavenCentral()
}


dependencies {
  compile('org.springframework.boot:spring-boot-starter-web')
  testCompile('org.springframework.boot:spring-boot-starter-test')
  compile('org.testng:testng:6.9.10')

}

test {
    useTestNG() 
    {        
        suites 'src/main/resources/testing.xml'

    }
}

有谁能帮我执行分级测试任务吗?

共有1个答案

姜德泽
2023-03-14

作为一个选项,您可以在测试任务中直接生成gradle中的xml,它在我们的项目中运行良好

useTestNG() {
    suiteXmlBuilder().suite(name: 'Default suite') {
        test(name : 'test') {
            classes('') {
                'class'(name: 'com.example.EmpBusinessLogicTest')
            }
        }
    }
}

要执行这个测试任务,例如使用Jenkins,您需要将系统属性传递给它:

systemProperties System.getProperties()
systemProperty 'user.dir', project.projectDir
 类似资料:
  • 如何运行一个测试用例的一个方法来调试Gradle?我试过: 但最终会出现以下错误: test类有、等。

  • 我无法用PHPUnit解决测试问题。这是我的密码,有点问题。这是年度百分比计算(https://en.wikipedia.org/wiki/Annual_percentage_rate ). 在cmd中: 不要考虑Oracle模块,这是另一回事。我在“composer安装”之后运行了“phpunit”。 项目/测试/测试概述。php: 项目/phpunit.xml 我解决不了,试了很多次:(

  • 22.13.1.执行测试 测试从main构建过程中分离出来的,运行在一个单独的JVM中执行.Test任务允许控制这些如何发生. 有许多属性用于控制测试过程如何启动.这包括使用诸如系统属性,JVM参数和Java可执行文件。 可以指定是否要并行执行测试.Gradle通过同时运行多个测试进程提供并行执行测试.每个测试进程在同一时间只能执行一个测试,为了充分利用这一特性,一般不需要为tests任务做什么特

  • 不是只使用,我们使用来包装它并完成依赖并在异步过程中执行测试。 使用需要我们返回一个Promise,我们通过调用或者来解决我们的测试的competition ,这取决于我们测试的结果。

  • 这是我的文件: 我已经尝试根据Github中的这个线程添加 自从我看到关于的消息后,我将此添加到我的中(通过各种google搜索): 如果有人对我如何调试这种情况有一些想法的话。

  • 我有一个与Kotlin的Gradle项目,有3个源代码文件夹(main,test,integration)。我想为单元和集成测试设置不同的分级测试任务。测试和集成文件夹的用途。我尝试了几种解决方案来设置集成测试任务,但到目前为止都没有工作。到处都提到我需要为集成创建一个不同的源集,添加一些配置以便能够正确地编译该文件夹中的代码,并设置任务本身。都做完了,但当我做测试的时候,他们失败了。然后,报告说