大家。
我正在使用Intellij IDEA和最后一个libGDX版本。
我在将buildNG依赖项添加到build.gradle文件时检查了some documentation。所以,我的build.grade目前看起来像这样。
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
jcenter()
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.6.0'
classpath 'org.testng:testng:6.9.4'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "SiliconStory"
gdxVersion = '1.6.5'
roboVMVersion = '1.6.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.6.0'
aiVersion = '1.5.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
jcenter()
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
testCompile 'org.testng:testng:6.9.4'
}
test{
useTestNG();
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "org.robovm:robovm-rt:$roboVMVersion"
compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
testCompile 'org.testng:testng:6.9.4'
}
test{
useTestNG();
}
}
tasks.eclipse.doLast {
delete ".project"
}
我已经创建了测试文件,主要问题是 - IDEA“无法解析TestNG类的符号”。因此,为了解决这个问题,我只是将库“test-6.9.4”(testNG库)添加到项目的类路径中。
如果我尝试开始测试,compilaton会失败。所有错误都是缺少TestNG包。我尝试刷新所有成绩项目,并再次在我的测试文件中,所有注释和testNG的导入都是红色的 将testNG库添加到类路径的警告和建议。
所以......我该怎么办?
PS:如果有必要,我会在这里提供测试文本。
public class BarTest {
Bar bar;
@org.testng.annotations.BeforeMethod
public void setUp() throws Exception {
bar = new Bar();
}
@Test
public void costAndCashTest(){
double cost = bar.getCost();
assertTrue(cost < 20.1);
}
@org.testng.annotations.AfterMethod
public void tearDown() throws Exception {
}
}
答案 0 :(得分:0)
我找到了解决方案! 我们应该添加的唯一内容是:
sourceSets.test.java.srcDirs = ["Tests/"]
到核心目录中的build.gradle文件。 “Tests /”文件夹是项目核心模块中所有测试的特殊目录。
因此,build.gradle文件文本应如下所示:
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project {
name = appName + "-core"
}
sourceSets.test.java.srcDirs = ["Tests/"]