Equivalent of Junit 4's #RunWith annotation in Junit 3.8 - java

What it the equivalent of using the #RunWith annotation for Junit 3.8? I've searched for a while on this, but Junit 3.8 is much older and I haven't been able to find much on the subject. We are using a 1.4 jre so Junit 4 is out of the question to use.

If I remember correctly we used to do our own TestRunner implementations that our suites extended.

Turns out we can use Junit 4 to execute tests with Junit 3.8 by using the Junit38ClassRunner which is included in Junit 4.

Related

JUnit4 vs JUnit5 with spring-boot-starter-test

The spring-boot-starter-test dependency adds both JUnit4 vs JUnit5 APIs
Is it OK if developers start using both and any?
Are there any problems expected when codebase have many both JUnit4 vs JUnit5 ?
I believe that is part of JUnit 5's vintage component that has backwards compatibility for JUnit 4

Equivalent for #RunWith(JUnitPlatform.class) for JUnit5

In my project I'm doing some cleanup and decided to move everything to JUnit5.
Till this time, I was using
#RunWith(JUnitPlatform.class)
Now I want to migrate it to #ExtendWith. Is there any equivalent for this JUnitPlatform.class in JUnit5?
You don't need it anymore when using junit 5.
In the junit documentation it states:
Annotating a class with #RunWith(JUnitPlatform.class) allows it to be run with IDEs and build systems that support JUnit 4 but do not yet support the JUnit Platform directly.
So since you are migrating to junit 5 I suppose your build system/IDE supports it. Hence, you don't need the annotation anymore.
Junit4 #RunWith has been replaced by #ExtendWith in JUnit5 as of content from https://www.baeldung.com/junit-5-runwith

Migrating specific tests from JUnit 4 to JUnit 5 in IntelliJ

I am trying to migrate test files from Junit 4 to Junit 5
using IntelliJ refactor code -> migrate -> junit 4 to junit 5.
But it only run import optimization and show all unit tests in the project and ask yes or no on refactoring and nothing happens when I chose do refactor.
any one know on another migration tool / plug in or a way to make the migration work ?
Jeanne Boyarsky created a tool to convert JUnit 4 based tests to JUnit Jupiter.
You can find it in her GitHub account: https://github.com/boyarsky/convert-junit4-to-junit5
Use openrewrite:
mvn org.openrewrite.maven:rewrite-maven-plugin:4.36.0:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:1.28.0 -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit5BestPractices
which migrates automatically from JUnit 4 to JUnit 5 without modifying your code style.
It seems that converting test from JUnit 4 to JUnit 5 in IntelliJ 2017.3 is not complete. As suggested by Sam Brannen there is a small application on Github called convert-junit4-to-junit5 that can do the job.
Just clone the Github repo and build the software using Maven mvn clean package. Then run the the application using
java -jar \
<path-to-your-cloned-repo>/convert-junit4-to-junit5/target/convert-junit4-to-to-junit5-0.0.1-SNAPSHOT.jar \
<path to where your JUnit 4 tests are located>
For further instruction please read the projects documentation.

Migrating from JUnit to TestNG in IntelliJ IDEA

I found information about migrating from JUnit to TestNG in general (here for example) and about working in IntelliJ IDEA with JUnit and TestNG separately, but nothing about migrating from JUnit to TestNG in IntelliJ IDEA itself.
Can anyone describe the steps required to do this?

Using JUnit and TestNG together

Do you think it's a good idea to use JUnit and TestNG together in one project? I need some features from TestNG, but I also need JUnit specific extensions, like DbUnit and XmlUnit.
And if I use them together, do you think I should put both test package trees in the same "test" folder in my Eclipse project?
DBUnit works fine with TestNG but nevertheless, you can run both JUnit 3 and TestNG tests at the same time: all you need to do is to put your JUnit 3 classes in a tag
<test junit="true">
</test>
and all your other TestNG classes in a regular:
<test>
</test>
Look for the string "junit" in the documentation for more details.
Why can't you use DBUnit with TestNG? As far as I can tell, it doesn't have anything specific to TestNG. Just have to define the import in TestNG's before test, and afterTest.
I would be surprised if XMLUnit couldn't be used in a similar matter.

Categories

Resources