Skip to content
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

PAXEXAM-674 Configurations and probe builders do not need to be static #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vincent-zurczak
Copy link

By default, JUnit parameterized tests with PAX Exam need static methods for configuration and probe builders. Notice that this is not mentioned in the documentation. When these methods are not static, you get a NullPointerException, as mentioned in PAXEXAM-674.

This patch allows to use non-static methods for configurations and probe builders.
The test class is instantiated with every configuration. And every test class instance comes with its own OSGi configuration.

This was tested with parameterized tests on Apache Karaf 4.0.2.
This patch also comes with support of custom names for parameterized tests (the name attribute of the Parameters annotation).

I asked for some feedback on JIRA, but nothing yet.
I hope more will come with this PR.

@hwellmann
Copy link
Member

Thanks for the patch - but we need some more info to apply it.

@vincent-zurczak
Copy link
Author

Hi. Thanks for the feedback.
I will add an integration test and format the code as expected.

- Repair the parameterized runner for non-PerMethod strategies.
- Add an integration test for parameterized PAX configurations.
- Format the code with the right formatter.
@vincent-zurczak
Copy link
Author

Hi. I have updated my patch.
First, having non-static methods for the PAX configuration only makes sense for the PerMethod strategy. I fixed it, although I took a strong hypothesis, that is to say I expect the test class to be annotated (default PAX settings are ignored). This could easily be fixed but I preferred limiting my modifications.

FYI, the use case I wanted to cover works perfectly (PerMethod strategy in Karaf, with parameterized configuration). This use case is illustrated with a new integration test. And I formatted the code with the right formatter.

However, I got some troubles with integration tests.
Those with Java EE never succeeded on my machine, before and after my modifications. And it seems my patch broke the Parameterized test. I get a NPE in the afterClass() method. There is probably something wrong with the run() method, but I could not determine what exactly. It is possible that I do not run the before and after class methods in all the staged reactors. To be honest, things are getting confused in my mind about this. If you have some clue or hint to give me, that would be helpful. 🆘

@vincent-zurczak
Copy link
Author

OK. I thought about it recently, and I think I will submit a new runner for tests that use a parameterized OSGi configuration. It will only suit PerMethod strategies with a real container. It is much more simple than upgrading the existing Parameterized runner (which already covers several use cases).

I will do it as soon as a I have some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants