我在this BitBucket repo找到了答案。 README給出了一個很好的解釋,說明如何使用Gradle來實現這一點。
基本上,你只需要添加GdxTestRunner.java從回購,然後添加一個@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
和bullet
依賴,如果你正在使用這些庫纔有必要。
在到位桶回購README,示例包括
testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
和
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
我不認爲這是必要的,包括本作compile
,如果我正確瞭解Gradle是如何工作的,它實際上會減慢你的構建速度。
這裏下載:http://libgdx.badlogicgames.com/releases/ 這裏解釋:http://agmprojects.com/blog/setting-up-a-basic-libgdx-project – Guillaume 2014-08-29 15:08:16
我想我應該提到我正在使用IntelliJ IDEA和LibGDX-setup-ui。我之前看過該教程,但由於它基於自定義Eclipse項目,所以似乎無法使其在我的項目中運行。 – twiz 2014-08-29 15:32:54
可能會有所幫助:http://stackoverflow.com/questions/1051640/correct-way-to-add-lib-jar-to-an-intellij-idea-project – Guillaume 2014-08-29 16:31:00