运行gradle脚本后,构建成功,但没有Reports,Test-Result文件夹显示在Build文件夹下。
Project strutcture is :
Gateway
src
com.pojo - Person.java
com.test -PersonTest.java
Gradle脚本:
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse'
tomcat_home='C:/apache-tomcat-6.0.37-windows-x64/apache-tomcat-6.0.37'
ext.projectJar = "C:/Users/r.kumar.verma/Desktop/referenceAppJar"
version = "1.0-${new Date().format('yyyyMMdd')}"
sourceCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
providedCompile 'javax.servlet:servlet-api:2.5'
runtime 'javax.servlet:jstl:1.1.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
compile fileTree(dir: projectJar, include: '*.jar')
}
**//This will publish the war to tomcat webapp.**
task deploylocal(dependsOn: build) << {
println "Copy from ${libsDir.getPath()} into ${tomcat_home}/webapps"
copy{
from libsDir
into "${tomcat_home}/webapps"
include '*.war'
}
}
在下面运行gradle测试后输出:
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
**After running gradle build, below is the output:**
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:war
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
I am not clear why the folders are not getting created under it.
I did clean build and all other things.
Person类只是一个带有String名称的POJO,测试只是检查输入和输出相等的断言。
Gateway
src
com.pojo - Person.java
com.test -PersonTest.java
Person.java:
public class Person {
private final String name;
public Person(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
PersonTest.java
import org.junit.Test;
import com.marriott.dsap.gateway.pojo.Person;
import static org.junit.Assert.*;
public class PersonTest {
@Test
public void canConstructAPersonWithAName() {
Person person = new Person("Larry");
assertEquals("Larry", person.getName());
}
}
答案 0 :(得分:0)
我找到的解决方案是按Gradle网站第23.4章 http://www.gradle.org/docs/current/userguide/java_plugin.html
所述组织项目布局您应该尝试创建文件 PersonTest.java 并将其放在 / ProjectXXX / src / test / java / PersonTest.java文件夹中 强>
它对我有用。