Gradle仅对主模块进行单元测试(使用Junit:4.11)(gradle多模块项目)
我目前正在构建一个项目,该项目依赖于我从 github 获得的另一个项目,但单元测试仅针对新创建的模块运行,有关如何让单元测试在整个项目中运行的任何提示吗?
当我 gradle test
时,我仅获得新模块的测试,当我 gradle :module2:test
时,我得到 Junit 成功测试了零测试。
架构
->new module (called app)
->build.gradle (call it 1- )
->github module (called module2)
->build.gradle (call it 2- )
->settings.gradle
->settings.gradle
Build.gradle 1-
plugins {
id 'rss.java-application-conventions'
id 'idea'
id 'com.adarshr.test-logger' version '3.2.0'
}
sourceCompatibility = 1.8
repositories { jcenter() }
dependencies {
implementation project(':xmlrss')
implementation 'org.apache.commons:commons-text'
testImplementation 'junit:junit:4.11'
implementation 'junit:junit:4.11'
}
repositories {
gradlePluginPortal() // so that external plugins can be resolved in dependencies section
mavenCentral()
}
version = '0.1.0'
application {
// Define the main class for the application.
mainClass = 'rss.app.App'
}
jar {
manifest {
attributes 'Main-Class': 'rss.app.MainClass'
}
}
test {
dependsOn(':module2:test')
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "short"
// set options for log level DEBUG
debug {
events "started", "skipped", "failed"
exceptionFormat "full"
}
// remove standard output/error logging from --info builds
// by assigning only 'failed' and 'skipped' events
info.events = ["failed", "skipped"]
}
}
Build.gradle 2-
plugins {
id 'rss.java-library-conventions'
id 'idea'
id 'com.adarshr.test-logger' version '3.2.0'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation group: 'org.apache.santuario', name: 'xmlsec', version: '2.0.8'
testImplementation 'junit:junit:4.11'
implementation 'junit:junit:4.11'
}
repositories {
gradlePluginPortal() // so that external plugins can be resolved in dependencies section
mavenCentral()
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "short"
// set options for log level DEBUG
debug {
events "started", "skipped", "failed"
exceptionFormat "full"
}
// remove standard output/error logging from --info builds
// by assigning only 'failed' and 'skipped' events
info.events = ["failed", "skipped"]
}
}
Settings.gradle(对于 module2):
rootProject.name = 'module2'
Settings.gradle(在根文件夹中):
rootProject.name = 'rss'
include('app', 'module2')
I'm currently building a project that depends on another that I got from github, but the unit tests only run for the newly created module, any hints on how to get the unit tests to run in the whole project?
When I gradle test
I get only the tests for the new module and when I gradle :module2:test
I get that Junit successfully tested zero tests.
Architecture
->new module (called app)
->build.gradle (call it 1- )
->github module (called module2)
->build.gradle (call it 2- )
->settings.gradle
->settings.gradle
Build.gradle 1-
plugins {
id 'rss.java-application-conventions'
id 'idea'
id 'com.adarshr.test-logger' version '3.2.0'
}
sourceCompatibility = 1.8
repositories { jcenter() }
dependencies {
implementation project(':xmlrss')
implementation 'org.apache.commons:commons-text'
testImplementation 'junit:junit:4.11'
implementation 'junit:junit:4.11'
}
repositories {
gradlePluginPortal() // so that external plugins can be resolved in dependencies section
mavenCentral()
}
version = '0.1.0'
application {
// Define the main class for the application.
mainClass = 'rss.app.App'
}
jar {
manifest {
attributes 'Main-Class': 'rss.app.MainClass'
}
}
test {
dependsOn(':module2:test')
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "short"
// set options for log level DEBUG
debug {
events "started", "skipped", "failed"
exceptionFormat "full"
}
// remove standard output/error logging from --info builds
// by assigning only 'failed' and 'skipped' events
info.events = ["failed", "skipped"]
}
}
Build.gradle 2-
plugins {
id 'rss.java-library-conventions'
id 'idea'
id 'com.adarshr.test-logger' version '3.2.0'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation group: 'org.apache.santuario', name: 'xmlsec', version: '2.0.8'
testImplementation 'junit:junit:4.11'
implementation 'junit:junit:4.11'
}
repositories {
gradlePluginPortal() // so that external plugins can be resolved in dependencies section
mavenCentral()
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "short"
// set options for log level DEBUG
debug {
events "started", "skipped", "failed"
exceptionFormat "full"
}
// remove standard output/error logging from --info builds
// by assigning only 'failed' and 'skipped' events
info.events = ["failed", "skipped"]
}
}
Settings.gradle (for module2):
rootProject.name = 'module2'
Settings.gradle (in root folder):
rootProject.name = 'rss'
include('app', 'module2')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论