-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to run Java tests #14
Comments
Sorry, this scalatest plugin is not designed to work in parallel with the normal gradle java Test task, it is designed to replace it. It writes reports and other files into the same locations as the java Test task; you cannot directly use both in the same project. If you require this behaviour then I suggest the following in your build file: // apply plugin: 'scalatest' - do not actually apply the plugin, but you still need to add it to your buildscript classpath.
import com.github.maiflai.ScalaTestAction
task scalaTest(type: Test) {
actions = [ new ScalaTestAction() ]
reports {
html {
destination = file("$project.buildDir/reports/scalatest")
}
}
} Please could you let me know if this works for you? |
@raymank26
And in your |
Thanks - yes, that is an option. In the past I've found that developers forget to include the annotation, which means that they can run the test from their IDE but the CI build will then ignore them. The common workaround is to create a base trait for all your tests, but developers can still forget to mix it in. You might also move the java tests to a separate subproject, or actively refactor them to scalatest. |
Closing due to inactivity |
I have this exact issue. @maiflai I tried the import... workaround you mentioned above but this fails in our multi-module build:
I tried adding the scala library as a buildscript dependency but this did not help. Still searching for a way to run both Scala and Java tests. I totally agree with your concern about using @RunWith - developers will forget to use it and it would be so easy to never notice, because the unit tests still pass. |
I think you've run into this issue: #17 (comment). Gradle is trying to launch the Scala REPL. Unfortunately the REPL doesn't work out of the box, you need to modify your project as per http://sethrylan.org/2013/07/02/scala-gradle-scalaconsole.html if you really want a REPL. My personal opinion is that the best way to run the junit tests is to move them to a separate subproject and use the normal gradle junit runner. |
I do not like the idea of moving junit tests into separate subproject (or moving scalaTests for that matter). It splits parts that logically belong together (code and its tests). It makes it harder to easily reuse test fixtures creates and obstacle for simple development. Defining a new
|
Can I ask why do you have two distinct testing frameworks in a single project? How does a developer know which one he should use? |
Legacy. Migration from Java to Java+Scala development means you inherit some tests and their rewrite is additional work to do. |
Then create a multi-module project and keep the legacy code and tests in the legacy project. It simplifies keeping track of what is legacy and what is not. |
One use case is integrationTest with spring boot in JUnit which is better supported, and use scalatest for unitTest |
By now this plugin redefines
test
task which is OK for Scala tests only. But when module contains Java tests there are no easy way to run them. As a workaround I suggest to renametest
task toscalaTest
for example.The text was updated successfully, but these errors were encountered: