-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Configurable Categories #503
Conversation
@dsaff can you please check the javadoc again. Now it should be ok. |
@@ -3,12 +3,6 @@ | |||
*/ | |||
package org.junit.experimental.categories; | |||
|
|||
import java.lang.annotation.Retention; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change the import order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it.
@aslakknutsen |
i have got a response from junit users, so i will update the javadoc accordingly |
Tibor, Do you think there's still momentum around this? |
@dsaff |
I will push new javadoc after Friday. |
This pull is also intended for surefire. The point is to specify more than one category. I would simplify the Javadoc and update JUnit wiki with more details. In this feature, we can include only tests annotated by SlowTests AND FastTests. Example: CategoryFilter slowOrFast = CategoryFilter.include(Selection.ANY/means OR/, SlowTests.class, FastTests.class); Similar with #exclude(). (without using the object Request, we can do the same using system properties) An example with a combined filter : Unless the Selection is specified, a default value is taken ALL for included and ANY for excluded. For more info regarding factory methods in class CategoryFilter: Thx, Tibor |
I have realized this is about more than what was asked two years ago. |
@gaffa We should now refactor the Javadoc and find out comprehensive text and tests covering the basic principle. I will concentrate on tomorrow. |
I can see your point. But joining Tasks may be the reason why the feature isnt yet included eventhough this was requested two years ago. |
No, it's not that reason. |
Here's one way you can help: imagine the implementation that you would want. Write the javadoc for that imaginary implementation. Think about every combination of possibilities. If, by luck, your desired implementation matches what @Tibor17 has built, then we can use your docs and go for it. If not, it may provide an alternate starting point for edits. Do you have time to help in that way? |
Javadoc for what, btw? The change that I am keen on is only in ExcludeCategory and IncludeCategory and changes the description from Class to Class[]. Are you talking about the whole categories-Package? |
I have studied that thread and all that I can find is that other related stuff got stuffed into the topic. "the tests" and "javadoc" still is damn inprecise ;) |
@gaffa |
I had a look into it just now. You will not like what I have to say. First of all the ALL/ANY concept is exactly what people would expect. I do not see a big benefit in making that optional (as its not a good idea to build such a complex test setup anyway) but you add a lot of complexity by doing so. Also ALL and ANY are not intuitive. In my opionion the possibility of building such a test setup is an over-engineered approach. @category({IT.class, Slow.class} @category(IT.class) @category(Slow.class) Whats the use in just running A? If I want to run classes that contain Integration-Tests and Slow-Tests why should I want to not run B or C? Makes no sense to me. You should find a use-case and illustrate it before adding such a feature. So much for Selection. Removing it would reduce the complexity a lot (with capital letters). As for the rest of the changes I am having another problem. Letting aside your changes I already think that Categories.java is coded in a way that is not easy to adopt. Easy to read-code, easy to adopt-design and common patterns are preferable to enable people to understand whats going on. Jumping into Categories does not give a good experience to the user at all. Your additions did not make that better. Its pretty clear you are a good coder but some patterns should be avoided when developing Java-code. Good code today is easy to understand at first sight and not reduced to the minimum using constructs only 10% of the people understand, using short field-names, few comments, ... My conclusion is that what happened here is exactly what i assumed before seeing the code. Too much got mixed in it and that resulted in a complex and hard to include result. For me that means that I think I will provide another pull request that introduces the concept of class-Arrays without the complexity of Selection. Really I am sorry to tell you but as far as I am concerned your solution is way to complex. If you really come up with a use-case for Selection you urgently need to work on the design to make it less complex. The concept is mixed in the code everywhere. You will need to encapsulate it somewhere else. Eg a service. The logic mixed in Categories needs to be stuffed in "generic" methods with documentation and names that are called from Categories to make clear whats going on. Do not be f* off by my comments and the fact that I am not aboard. I mean well. Maybe someone from the outside looking into it and giving honest and detailled feedback also helps. |
As in #142, this is what we agreed we want. Again the most important thing is now the Javadoc to concentrate on. We would need the ANY/ALL to satisfy two parties of users. This is what we understood in #142. There we were exactly two groups. I have also new tests which improve the Javadoc, but no time to finish it. If I have to submit a change, then it has to satisfy more than your needs. We are not developing for one user, right? |
Yeah, right. I did not see that there was a pull request with the simple approach already that was discussed until it died. But in the end JUnit is for the developers using it, not those developing it. And the behaviour that all Classes specified in the Annotation is what is expected. Really. :) |
@gaffa |
I have to disagree. This is an effective compromise which is 100% compatible to your approach. Its just a way of getting a feature in without waiting for you sorting things out. It has already been two years. And you really cannot expect me to fix your documentation or to finish your feature (which again: is a compatible addition). I have spent time looking in your stuff and given you feedback. Afterwards I decided that this feels far from finished and suggested a compromise that allows you to work on it when you find the time. I think that is a perfectly fair solution. Talking about the communty: do you really think that they would have not liked to have the feature without Selection 23 months ago rather than waiting until ...? Also: the feature is 100% backwards compatible and 100% compatible to your feature. I dont get the problem. Also: the inital request was exactly what I implemented. You rocket-sciencing it does not mean that request is not as valid as it was 2 years ago ;) |
To gain peace I have decided to implement your feature in a way I think it makes the most sense (I dont think anyone will use it but anyway. I dont want to be blamed for only representing my interests again). Its not finished. I just spent <1 hour at work. But maybe it gives you a hint at how to simplify your feature. https://github.com/gaffa/junit/commit/99fcd8ee32de4b8c7e1bafdc18946ac56db5c6a5 Still there are three methods that I would extract to a Utility-Class as they pretty much do generic operations (the Class<?> - stuff) |
的很贵 |
@dsaff
I still prefer using Set-s instead of arrays or List-s because class duplicates are not welcome. Failsafe against null in annovation values. Ready for use in other open source projet maven-surefire because of CategoryFilter factories. |
Cool. Would love to see it merged in soon. |
Now the indentation is fixed. |
Offtopic: Is there a complete styleguide for junit anywhere (indentation, brackets, imports, ...)? Maybe I will find time to configure intellij and export the settings. Someone could do the same for netbeans and eclipse. Would make things a lot easier for new people. Default IntelliJ-settings are completly different than junit style and thats why I cant use autoformat at all. |
Fulfilled all previous requests from @dsaff and going to merge with master. |
@gaffa |
Thanks! |
@Tibor17, what do you mean "This branch has wrong parent, so cannot be merged"? There's so much history on this pull that I'd love to get the original merged, unless its' just become prohibitive. What happens when you try to merge? |
I updated my project. I found out that the changes come from branch gh-pages, without latest changes in 4.12. |
@dsaff |
Done |
all tests passed |
Very glad to see this one reach the finish line! Thanks! |
Can you take a stab at the release notes, as well? |
Yay! (and good night everyone ;)) |
@aslakknutsen To all contributors in #142 regarding multiple categories. |
Congrats on pushing this through guys. We'll be glad to be back on the Big props to @gaffa for bringing this back to life and @tbor17 for On Monday, December 10, 2012, Tibor17 wrote:
Andrew Matheny |
BTW: this change removed a public constructor. I'm putting together a pull to add it back. |
Categories in suite should be multiple in annotations Categories.IncludeCategory and Categories.ExcludeCategory, and configurable by system properties as well.
This pull request referst to discussions in #142 and my old pull request #354 closed by my mistake #461.