开发者

Run tests in broken project using SBT

When doing a serious refactor in a Java Eclipse project I will often break the build, but focus on getting one test to pass at a time. When running the tests Eclipse warns that the project cannot be compiled, but it will still run the tests it can compile.

Now I'm using SBT and would like to achieve the same thing with 'test-only', but it tries to compile the whole project, fails, and doesn'开发者_如何转开发t run the tests. How can I tell it to just compile the bits it can and run the tests.


You should add the following task to your project definition:

import sbt._

class Project(info: ProjectInfo) extends DefaultProject(info) {

  lazy val justTest = testTask(testFrameworks, testClasspath, testCompileConditional.analysis, testOptions)

}

This is the same as the ordinary test task, but has no dependencies attached at the end. If you'd like it to have dependencies, call dependsOn on the testTask(...) expression and provide the tasks you want it to depend on.

testTask(testFrameworks, testClasspath, testCompileConditional.analysis, testOptions).dependsOn(testCompile, copyResources, copyTestResources) 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜