我有一个使用TestNG运行的简单代码,但我无法使用Gradle运行相同的内容,因为它说没有找到主要方法,这也就是说,因为我正在使用注释,这并不奇怪.
但在这种情况下,如果必须使用Gradle,如何运行代码.
请注意,我对Gradle很新,并且对此并不了解.
码:
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class tryTestNG
{
@BeforeClass
public void setup()
{
System.out.println("I am in Setup");
}
@Test
public void test()
{
System.out.println("I am in Test");
}
@AfterClass
public void tearDown()
{
System.out.println("I am in tearDown");
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码与TestNG Library完美搭配.但不是Gradle.
这是我的Gradle Build设置:
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'tryTestNG'
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
test {
useTestNG()
}
dependencies {
compile group: 'org.testng', …Run Code Online (Sandbox Code Playgroud)