TNG / junit-dataprovider

A TestNG like dataprovider runner for JUnit with many additional features
Apache License 2.0
246 stars 164 forks source link

ClassRules do not work anymore #35

Closed janschaefer closed 10 years ago

janschaefer commented 10 years ago

Since v1.9.0 ClassRules (since JUnit 4.9) do not work anymore.

See ClassRuleAcceptanceTest for a test showing the issue.

janschaefer commented 10 years ago

I currently see no obvious solution for the problem, because the current code depends on JUnit 4.8.2, but the ClassRule-Feature requires 4.9. So either 4.8.2 support must be dropped or ClassRules must be called by reflection.

janschaefer commented 10 years ago

I also had to ignore the test testFilterShouldWrapGivenFilterWithDataProviderFilter not sure, however, whether this is a actual problem or not.

janschaefer commented 10 years ago

I am wondering how important JUnit 4.8.2 support is. Maybe create version 2.0 and drop support for JUnit < 4.9. Bug fixes could then be still done on the 1.x branch. On the 1.x branch you could remove the BeforeClass feature and instead implement it only for JUnit 4.9 in the 2.x branch. What do you think?

Update: Actually I might have found a solution to stil support 4.8.2, please have a look at the pull request.

aaschmid commented 10 years ago

First of all, fixed by reverting changes for supporting @BeforeClass (d00a289, #22)

Can you review and approve this using the new 1.9.1-SNAPSHOT version?

janschaefer commented 10 years ago

sure

janschaefer commented 10 years ago

Ok, all JGiven tests work again :-). The revert looks fine to me.

aaschmid commented 10 years ago

Now to the other comments/questions:

I also had to ignore the test testFilterShouldWrapGivenFilterWithDataProviderFilter not sure, however, whether this is a actual problem or not.

This is because they changed the internal behaviour for filtering tests a bit, but only the test breaks, not the code!

I currently see no obvious solution for the problem, because the current code depends on JUnit 4.8.2, but the ClassRule-Feature requires 4.9. So either 4.8.2 support must be dropped or ClassRules must be called by reflection.

Yes, I have had the some problem here, but I made the mistake to try to support just @BeforeClass and oversaw that this breaks the @ClassRule feature in later versions of JUnit.

I am wondering how important JUnit 4.8.2 support is. Maybe create version 2.0 and drop support for JUnit < 4.9. Bug fixes could then be still done on the 1.x branch. On the 1.x branch you could remove the BeforeClass feature and instead implement it only for JUnit 4.9 in the 2.x branch. What do you think?

You are right, I thought the same quite a long time ago. And as you said, I am also not willing to loose JUnit 4.8.2 support in junt-dataprovider 1.X.Y. I am just not sure if I should rather upgrade directly to JUnit 4.11 as it have been released for a quite long time now and they changed some internal behaviour ... (as the filter stuff above, also they deprecated some more stuff ...) Same question a bit for which Java version to use ...

Update: Actually I might have found a solution to stil support 4.8.2, please have a look at the pull request.

This, indeed, looks quite good and I have merged your changes into branch execute.beforeClass.before.dataprovider.