How to run all scalatest of a multi-modules sbt with intellij? - scala

I can run:
a specific scala test
either by right clicking on the test and choose run
or if I have run it once previously, by selecting the test in run menu > run...
I can run all junit tests by making a new run/debug configuration > + > junit > test kind = all in package > search for tests = in whole project
I can run all scalatest (or junit) of one sub-project: right click on the project > run > scalatest in [module name]
But if I do the same as (2) with a scala test (+ > scala test > test kind...) the first test fails very strangely (it seems an object is not instantiated) while the same test pass if I run it using (1) or (3)
Config:
sbt with multiple subproject
intellij CE 15.0.2
scala plugin 2.1.0
scala 2.10
Bonus question: how to run all tests (junit and scalatest)?

You should be able to right click on the root directory of the project and click Run "All Tests". This recursively searches for tests in your project, and will run the tests in each module.

Related

Cannot "Run as JUnit Plug-in test" on test plugin/package (JUnit5)

I'm trying to add JUnit5 support in my Eclipse RCP application. It almost works, because for now I can:
Use Maven to build whole application and run tests with Tycho
Run single JUnit5 tests (creating run configuration on specific class) in
Eclipse
Run single JUnit5 tests in Run as JUnit Plug-in test mode in Eclipse
Run multiple JUnit5 tests in Run as JUnit test mode in Eclipse
What I'm trying to achieve now is to be able to run whole sets of test classes in plug-in test mode. For JUnit4-based plug-ins I could simply right-click on whole package or even whole plug-in and invoke Run As -> JUnit Plug-in test.
When I do the same operation on JUnit5 tests I get an error: No tests found with test runner 'JUnit 5'.
My current configuration for such plug-ins looks as follows:
According to official instructions in MANIFEST.FM I have Import-Package dependencies:
org.junit.jupiter.api,
org.junit.jupiter.params,
org.junit.jupiter.params.provider
and org.junit as Require-Bundle dependency
In order to run tests in Eclipse IDE I've also added JUnit 5 library to Java Build Path of the plugin. I coudn't add JUnit 5 runner dependencies to MANIFEST.FM instead, because of conflict with Tycho.

SBT - why sbt giving compilation errors while running?

I am trying to merge two modules into single module. Both are successfully running modules. I merge two modules. And trying to run the test cases.
i am compiling source and testcases by using sbt commands:
sbt
clean
compile
project module-read
test:compile
it:test
Till test:compile everything working fine but after it:test, it showing lot of compilation issues.
Could I know best way of compiling?
The test:compile task will only compile tests within the src/test/scala folder as per the default sbt test configuration.
In order to compile your integration tests (in src/it/scala) you will have to run it:compile .
See http://www.scala-sbt.org/0.13.5/docs/Detailed-Topics/Testing.html#integration-tests for more info.

How to set up IntelliJ external Scala compiler for Maven projects

I'm using IntelliJ 13 community version. I have a Maven project with multiple modules.
Currently, I'm using IntelliJ internal compiler. I find that every time I run maven clean XXX, I have to manually trigger Scala rebuild in IntelliJ before I run any Cucumber acceptance tests. Otherwise IntelliJ will complaints "no class file". It is annoying. It takes 2 to 3 minutes for the clean re-build.
Finally, I decide to try the external compiler. I have no idea how to do it. I does not seems as easy as enable external compiler.
Can any one please teach me how to properly set up external compiler for a multi-module maven Scala project?
Maven clean command deletes your jar and target folder.
therefor you need to compile the maven project with the maven command "compile" / "install" after clean .
if you want to use your command line to clean and compile you can run $ mvn clean compile . but actually since "clean" is the 1st step at maven's build life cycle you only need to run the compile command . it will run "clean" (or $ mvn compile) as the 1st step of the build .
check out maven build life cycle here

Tests in a maven project do not run with Netbeans but run fine with Eclipse. maven-surefire-plugin

so essentially I have a big maven project. When I open it in netbeans, strangely if I add any new junit test class or even if I rename existing test classes I cannot run any of them using "Test File", but old test classes run fine. I receive a message:
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-cli) on project sga: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
Strangely, if I open the same project with Eclipse, all new and renamed classes run fine without errors with "Run As JUnit".
Could help me to make the new tests run in netbeans? Thank you

m2eclipse: Like "mvn test" but with GUI?

We have a multi-module Maven setup with a master pom.xml that includes all the others. So mvn test from the root directory runs all our unit tests, with textual output.
I can do Run / Run As / JUnit Test to run a single test class with a graphical test runner.
Question: How do I combine the two, so that I can run all the tests that mvn test runs but with a graphical runner, like the one from Run / Run As / JUnit Test?
Create an eclipse project with all your modules as Maven Dependecies and then create a JUnit Suite which incorporates all tests. Eclipse's JUnit Runner then will execute all declared Tests if you run this suite.
In Eclipse Juno, assuming your project is a Maven Project, you can just right click the project name in the Project Explorer and select Run As ... jUnit test. Alternatively you can produce the same text output you get from mvn test by selecting Run As ... Maven test