我在此BitBucket存储库中找到了答案。自述文件很好地解释了如何使用Gradle来实现这一点。
基本上,您只需从该存储库中添加GdxTestRunner.java,然后将a添加@RunWith
到每个测试文件中:
@RunWith(GdxTestRunner.class)
public class MyClassTest {
...
}
然后在您的根级别build.gradle
文件中,将以下内容添加到您的core
依赖项中:
testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
testCompile "com.badlogicgames.gdx:gdx:$gdxVersion"
testCompile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
testCompile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
testCompile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
testCompile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
testCompile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
显然,仅当您使用这些库时,box2d
andbullet
依赖项才是必需的。
在BitBucket存储库README中,该示例包括
testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
和
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
我认为没有必要将其包括在内compile
,如果我正确理解Gradle的工作原理,实际上会减慢您的构建速度。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句