We are using JUnit 5 in a new project, and it has removed support for #Rule I would like to know:
Why do the current unit tests use #Rule on the TestPipeline?
Is there a JUnit 5 alternative extension?
Apache Beam currently depends on JUnit 4.13.0.
Feel free to create a JIRA to address this. Any contributions related to this are welcome as well.
Related
i m working on a grails project and i want to add tests to it.
I used spock and Geb but i prefer JUnit but it doesnt work.
i m creating a new Groovy Test with the eclipse wizard, i select either junit4 or junit 5
then it creates a new test class
i right click and select run as> Junit Test
it should show the junit view with failing test but no
i get a lot of "Invalid package binding for default import java.util/net/io"
and a "could not retrieve superclass","AbortCompilation ... AssertionError cannot be resolved. it is indirectly referenced from required .class file"
from org.eclispe.jdt.core
and i get an invocationTargetException caused by a NPE from org.eclispe.jdt.junit
those are my last errors from my many attempts, i feel like it s just impossible to do it.
if someone managed to make it work, pls tell how you did it
regards
test Grails 3.3.8 app with junit 4 or 5 in eclipse 2018-12, is it
possible?
Yes, it is. There are numerous ways to do that.
A common way to do that is to create a launch config in Eclipse that will execute the test or integrationTest Gradle task with the appropriate parameters.
I am looking at migrating the unit tests for a set of projects from JUnit4 to JUnit5. This is proving to be generally pretty straightforward. However there is one problem outstanding: how to run unit tests across all projects from within Eclipse.
With JUnit4 there is a simple solution using ClassPathSuite: create a new project which has all the other projects on it's classpath and add a single class with no methods:
#RunWith(ClasspathSuite.class)
public class RunAllTests {
}
This still works fine with tests written for JUnit4 and run with JUnit5 using the vintage engine. However once tests are converted to native JUnit5 ClassPathSuite no longer finds them.
Eclipse Oxygen (v4.9.0) Test configuration only allows tests to be configured within the confines of a single project, package or source folder so does not appear to offer a solution to this problem.
Any suggestions?
JUnit 5.8 introduced #Suite and suite engine.
This functionality seems to be similar to what ClasspathSuite JUnit 4 extension offers.
Eclipse seems to be working pretty well with JUnit 5 suites:
All the tests on the screenshot come from different projects.
I really like using the Deltaspikes Datamodule with its Repositories.
To improve in productivity and lower the Errors i am also writing Unittests via JUnit.
Before i used DBUnit with Plain JPA/Hibernate inside the testcases, but i would like
to test my deltaspike JPA repositories via JUnit - or maybe enhanced with DBUnit.
Are there any best practises or ways how to do this?
I found some integration project that combines dbunit with Deltaspike, but i was not able to getit running with Hibernate JPA Provider.
https://github.com/lbitonti/deltaspike-dbunit
Thanking you very much in advance for any help
Best regards, Shane
I was able to do this by using Database Rider.
I really can recommend this project for all people who want to have a foll integrated JUnit 5 Test combined with Apache Deltaspikes Repository structure
https://github.com/database-rider/database-rider
I want to develop JUnit 4 tests only. When writing Unit Tests, Eclipse often imports classes from junit.framework, which is JUnit 3.
This has lead to various problems, e.g. when expecting an Exception, it simply doesn't catch it if it's in the wrong package like this:
import static org.junit.Assert.*;
import junit.framework.ComparisonFailure;
[...]
try
{
assertEquals(0, 1);
}
catch(ComparisonFailure cfe)
{
}
Strange enough, if I Ctrl+Click on ComparisonFailure, it says
Source not found
The JAR of this class belongs to container 'JUnit 4' [...]
Perhaps helpful environment information:
I don't have JUnit 3 in my build path.
Eclipse Luna 4.4.1
How can I stop Eclipse from importing JUnit 3 classes?
I have read Why is Eclipse using JUnit 3 when I have junit-4.3.1.jar in my build path?, but it's rather old and probably does not apply to Luna any more. Also, my problem is not in running the test, it's in implementing the test.
Another workaround for Eclipse's users is the following solution:
Windows -> Preferrences -> Java -> Appearance -> Type filters
and add junit.framework.* to the exclusion list.
Actually, JUnit 4 depends on some of the classes that were developed originally within JUnit 3 or reside in packages junit.*. One of such class is ComparisonFailure. If you look at latest JUnit 4.12 you will see that these packages are still there.
However, sources jar do contain java files for these classes. Perhaps your library that contains JUnit (do you use Eclipse JUnit library?) lacks source files for these? Where does your dependency (junit.jar) come from?
Which dependencies has your plugin ? Junit 3.X or 4.X ?
You could search your workspace for any references in junit 3 and change/remove them.
In the google-collections gtug videos there was a mention of test suite generator and plans to open source it.
Currently in guava git project there are two maven modules
guava-testlib
guava-tests
Are these two modules the next version of the test suite generator?
At cursory glance the code within these modules seemed very much specific to guava project.
Is there an easy way to utilize the library/code/strategies used in test suite generator?
Yes, the automatic test suite generator for testing collection implementations is the bulk of what's in guava-testlib. This post explains how to use it.