栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Gradle编译但不运行TestNG测试

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Gradle编译但不运行TestNG测试

这确实是一个愚蠢的菜鸟错误。我们正在使用一个多项目设置,其中包含一个主项目和几个位于同一级别的文件夹,其中包含代码和测试。在

build.gradle
我使用不慎唯一配置的主项目使用TestNG的。解决方案是将测试目标包含在
allprojects
subprojects
闭合内。这里解释:所有项目和子项目之间有什么区别

所以这里是工作

build.gradle

def mainClassName = 'nl.xillio.contentplatform.view.Run'// Load settings for all projects including master and subprojectsallprojects {    apply plugin: 'java'    apply plugin: 'eclipse'    version '0.1'    repositories {        mavenCentral()        maven { url 'http://mvnrepository.com/maven2'        }        maven { url 'http://download.java.net/maven/2'        }    }}// Load the dependencies for all subprojects (layers)subprojects {    dependencies {    //to do: move these to the correct subprojects        compile 'javax.inject:javax.inject:1'        compile 'org.springframework:spring-context:4.1.4.RELEASE'        compile 'org.springframework:spring-core:4.1.4.RELEASE'        compile 'org.springframework:spring-beans:4.1.4.RELEASE'        compile 'commons-logging:commons-logging:1.2'        testCompile 'org.springframework:spring-test:4.1.4.RELEASE'        testCompile 'org.testng:testng:6.1.1'    }    test {        // enable TestNG support (default is JUnit)        useTestNG()     }}// Resolve the dependencies between the layers in the individual project's build.gradle files// add onLY specific per project behaviour of the GLOBAL build here:project(':contentplatform-web') {}project(':contentplatform-service') {}project(':contentplatform-dao') {}// Return a list of all the external librariesdef getLibraries() {    return configurations.runtime.filter{!it.name.startsWith('contentplatform')}}// Copy all the libraries to a libs foldertask copyLibraries(type: Copy) {    group 'Content Platform'    description 'Copy all the external libraries to the /libs folder.'    destinationDir file('./build/')    into('libs/') {        from getLibraries()    }}// Perform the build task before building the big jarjar {    group 'Content Platform'    description 'Package all the layers and dependencies into a big jar.'    // The libraries are required to build    dependsOn(copyLibraries)    // The final big jar needs all the layers    dependencies {        compile project(':contentplatform-web'), project(':contentplatform-dao'), project(':contentplatform-service'), project(':contentplatform-model')    }    // Create a MANIFEST.MF file, the main class file is in the web layer    manifest {        attributes 'Implementation-Title': 'Content Platform',   'Implementation-Version': version, 'Built-By': System.getProperty('user.name'), 'Built-Date': new Date(), 'Built-JDK': System.getProperty('java.version'), 'Class-Path': getLibraries().collect{'../libs/' + it.getName()}.join(' '), 'Main-Class': mainClassName    }    // Include the layers in the fat jar    from(configurations.compile.filter{it.name.startsWith('contentplatform')}.collect{it.isDirectory() ? it : zipTree(it) }) {        exclude "meta-INF/*.SF"        exclude "meta-INF/*.DSA"        exclude "meta-INF/*.RSA"    }    // Save the fat jar in the root of the folder instead of in build/libs    destinationDir file('.')}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/570579.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号