I have a Gradle project that I would like to use infinitest with. However, while all test pass using the Gradle test runner, many fail in infinitest. Is this because infinitest uses the IntelliJ test runner to run the tests?
I expect this is the case since I get similar results when I try to run tests manually using the IntelliJ test runner.
How can I configure infinitest to use Gradle as the test runner?
Infinitest starts a new JVM to run tests, it gets the project classpath from IntelliJ but does not know it is a Gradle project.
I don't know what the Gradle test runner does differently but it would be great if you could open an issue on the Infinitest bug tracker with the steps to reproduce the problem (ideally with a sample project).
In case the issue is with missing JVM options you can set them using the infinitest.args file
My Gradle Project Cannot Run JUnit Test in IntelliJ IDEA 2016.3 version.
When I Use #Test Annotation and Run it, it executes as a Gradle Task, notas Junit Test. When I Click right hotkey on test method, not exist 'Create Junit ..'
option (this option is available in last version.)
I installed idea Junit Plugin.
It's working on IDEA 2016.2 version.
has anyone see the same problem?
it's my project config error,
just modify Settings -> Build, Execution, Development -> Build Tools -> Gradle -> Disable Delegate IDE build/run actions to gradle resolve this problem.
I have a simple question. Is there a way to configure NetBeans so that after build JUnit tests in test package would run automatically ? I'm using NetBeans 8.0.1.
Thanks in advance.
If you are using Maven there's an option under Tools / Options / Java / Maven / Execution / Skip Tests for any build executions not directly related to testing. Make sure that this one is unchecked.
If you are using Ant this is also possible. It's been some years since I used Ant but from top of my head you need to modify your build.xml. There needs to be a target like "compile" and there you add in the depends-property the targetname for the unit tests.
For a project specific solution:
Right-click on your project -> Properties -> Actions.
Select "Build project" ("Debug project" and "Run project" work too!"
Add "surefire:test " at the beginning of the Execute Goals.
If you now share your source code with others, they will automatically run your tests too!
I'm working with a multi-artifact Maven project where artifacts in the project have a few dependencies on each other. I am using IntelliJ 9. I'd like to be able to set breakpoints in my unit tests, but when I right-click on the unit tests folder for my artifact and choose "Debug 'All Tests'", I get a Class not found exception referring to a class in a separate Maven artifact.
I can run the Maven "test" goal on the parent artifact and it works fine.
Any ideas? Thanks.
In you run Maven from command line, you will be able to run it with debugger enabled and just attach Idea as remote debugger. That's how I usually use it.
mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" test
See http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html
This will allow debugger connection to port 8000 and wait for you to attach before execution.
I wanted to run the unit tests for a specific package.
I was able to get this to work by making a new JUnit run/debug configuration in IntelliJ. I told it to run the tests in the specific package and for "Use classpath and JDK of module", I picked the root Maven artifact.
I created a JUnit 4 test in Eclipse by right-clicking on a Java class and selecting New JUnit Test Case. When I right-click the test class I get "Run on Server", but not "Run as JUnit Test". I am using Eclipse 3.6.1.
In my case, Eclipse must have reached a corrupt state. Restarting Eclipse fixed the problem.
I think I see the problem. You need to have an actual test in the file before Eclipse identifies it as a test case. Try inserting the following:
#Test
public void foo() {
}
for junit5 jdk8 is needed in build path and project facets.
Make sure your class has JUnit traits (extends from TestCase, or use #Test etc);
Right-click "Run As" -> "Run Conciguration" -> Create JUnit test from left icon "JUnit" anyway;
check whether you have jave 8 or above and configured correct jdk in build path.
check at least #Test is used in your test case class file
Then go to run configuration->select Junit->right click and new configuration->browse the package->select junit5 as test runner.
In case you experience it in maven project add following into pom.xml and reload project using Alt+F5. Tests do not work because old JDK version.
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Make sure to have a valid default constructor for your test class.
In my case, the problem was different. I was converting a TestNG test to JUnit. The #Test annotation was satisfied by the TestNG import, but that was the wrong annotation. I removed the TestNG import and added the JUnit import for #Test, and the right-click menu option to run as a JUnit test appeared.
The eclipse shortcut to run Junit test is Alt+Shift+X, T.
If its not working just press Alt+shift+X a menu will popup just look for Junit.
I ran into these symptoms when importing an existing project into a Kepler-based Eclipse IDE for Java Developers version.
Importing the project into a Luna-based Eclipse IDE for Java EE Developers correctly set set it to a Java project (project icon now includes that little J) and now allows running JUnit tests.
In my case the Java Build path (.classpath file) was corrupt. In particular it had a merge conflict which was unresolved. Therefore, the JUnit 4 library was missing.
I used to have a similar problem and it turned out that was because I forgot "extends Specification" after the "ClassToBeTestedSpec" in the declaration.
Make sure that you include import org.junit.Test; and the tests have #Test before them, I have missed that before when coping some functions from other files.
To solve the situation, a restart of eclipse wasn´t enough in my case, I had to remove and re-add the project to my workspace as well.
If, the configuration is of SpringRunner.class for Junit.
Make sure your maven clean install with maven update and refresh is run in your project with right jdk and mavens password/configuration.
This recurred for me, this time it was that Junit simply wasn't added to the classpath (but it has in the past been). This is the first Eclipse project for me to use Junit 5. Maybe that has something to do with it? I know this is a very old post, but I think this might be needed for more recent reasons.
Right-click your project and choose 'properties'
choose Build Path -> Configure Build Path
Click on Libraries tab.
Click on Add Library button.
Click on JUnit and Next button.
Choose JUnit version. (for me, Junit 5)
Click Finish.
Info From
https://www.eclipse.org/forums/index.php/t/304679/