-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce extension API for container templates #871
Comments
Defining |
In parts. But it would still make the method the container for multiple tests instead of the class. And it would also require all methods to have the same parameters. |
Spring users often ask for such capabilities -- for example, see SPR-16302. |
Although SPR-16302 is a recent JIRA issue for spring, the topic has been raised multiple times over the years with regard to Spring's integration with JUnit 4. More recently, Spring users have begun to ask for such a feature in conjunction with JUnit Jupiter. |
With regard to generic support for iteratively executing an entire container (test class), something like Thinking out loud... Spring already has its own annotations for declaring things like active profiles, context configuration classes, etc. Thus, it would not make sense for a parameterized Spring test class to make use of annotations from Jupiter such as Thoughts? p.s. |
Moved to 5.1 backlog due to repeated requests for a feature like this at conferences, etc. |
Another potential application: #723. |
The lack of lifecycle methods like Unfortunately, JUnit5 does not provide access to the test parameters within Having both JUnit4 and JUnit5 classes on the classpath is problematic as it creates havoc of tests in different styles. A year ago @sbrannen said the team decision was to add two classes and an annotation. Does anybody work on that? Of course, I understand there's a bit more work besides adding a couple of classes, however, the lack of lifecycle support for parameterized tests does impact users. |
It's true that JUnit 4 does not support JUnit Jupiter's exception for failed assumptions. However, JUnit Jupiter actually supports JUnit 4's exception for failed assumptions. Granted, that does not eliminate the issue, but it does help a little. |
No, we do not put issues of this nature "up for grabs" due to the complexity and impact on the entire internals of JUnit Jupiter.
Yes, that's an understatement. 😇 The complexity of the implementation is actually what has kept us from tackling this one. The simple (unfortunate) fact is that no one in the core team has had the time to take on this issue. In other words, this is likely something that will require weeks of work to implement, and that does not account for tests, documentation, interoperability with third-party frameworks, etc.
We are aware of such issues and truly hope to make progress on this issue during the course of 2024. |
We didn't quite make it in 2024 but a PR is now ready for review: #4315 |
Let me know if I can help with testing. Thanks for working on this 🙏🏻 . |
Test templates are a great way to create extensions that generate test cases per method. If an extension wants to generate suites of tests per class, though, this is not easily possible. I propose to implement a container template extension point that functions similarly to test template:
n
- but in this case per container, which makes Jupiter work all its "execute tests in this class" magic not once butn
timesIt might make sense to consider whether other extensions should be allowed to easily access the container invocation context, maybe from the
ExtensionContext
they already receive. (Thinking about that, wouldn't it make sense to do the same for test templates, i.e. giveExtensionContext
a method that returns the invocation context?)Where parameterized test methods were the canonical example of how to use test templates, theories would be the canonical example for container templates. With this extension point the theories extension would use reflection to find out how many parameters were defined and then have the class be executed so many times, each time dropping a different set of parameters into all test methods:
a = 0; b = 0
testAddition(a, b)
testSubtraction(a, b)
a = 0; b = 1
testAddition(a, b)
testSubtraction(a, b)
Related Issues
The text was updated successfully, but these errors were encountered: