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
@Test(enabled=false) annotation at class level should disable all the methods in the class #151
Comments
Hi Nicolas, You should see this if you don't use any @test method on your methods, but as soon as you do (like you do in your example above with dataProvider) then the Does this make sense? |
Yes, Thanks Cedric. I make the wrong assumption that the annotation @test(enabled=false) on class exclude entirely the class from execution |
I agree it's a bit counter intuitive, but it's too late to change now, sadly... |
Hi, Cedric! |
I'm afraid this makes things more confusing now that you need to explain the subtle difference between The current |
Hi Cédric, I've actually run into this issue as recently as last week. I am working on a web server that relies on the Facebook Graph API. I had a test class that had some test methods relying on code hitting the Graph API, with other test methods not needing to rely on that service at all. Then, there was a global outage on Facebook as a whole for more than an hour. This resulted in some of the tests in this class failing. What I was hoping to do, in order to keep the rest of my development team unblocked, is just disable all of the tests on this class immediately, via a @test(enabled=false) annotation on the class level. Of course, that didn't work. Instead, I had to disable each failing test method one-by-one, taking me more time than desired, or even necessary to solve this problem. Ideally, TestNG supports some sort of functionality similar to JUnit's @ignore annotation: http://junit.sourceforge.net/javadoc/org/junit/Ignore.html. Long story short, developers are indeed desiring this functionality. Thank you. |
@ecbrodie This is already supported (try it!) but there is a caveat: every individual method that has a
This is due to the semantics that attributes at the method level override attributes defined at the class level, so the method level Makes sense? |
Hi @cbeust , thanks for that example, but that was already the understanding of the problem, so I think you may have misunderstood me. That point that I was trying to make was, given the current semantics of @test(enabled=true/false) and the desire to have a way to indeed specify an override of enabled on the class level to ignore whatever is set at the method level, perhaps it is time to reconsider your stance against adding in some sort of You seem to indicate some disdain towards the original approach you took with @test(enabled) semantics. If that is indeed the case, then why not bring its semantics to something that you feel is more intuitive? |
Agreed, I think a Maybe you or @juherr would be interested in submitting a PR? |
I'm not feeling it good. I don't like the idea to add a new attribute which only be used on class. BTW, what I propose instead is to provide a |
@juherr Cool PR, it's indeed very simple to do with an My only concern is that for the user, it's a bit more arcane to use, as opposed to an Note that we already have a few attributes that are only applicable at the class level ( |
As I said, I don't like the use case. And I suppose it will be enough for the only 2 persons who asked it in the 4 last years :) |
@cbeust |
Yes, it is what #816 proposes |
@juherr |
What If I have a scenario as below:
|
@Rameshwar-Juptimath What is the relation between you sample and this issue? |
Due to these non intuitive behavior of @test at class and method level. |
@aliciatang The behavior is the same for all the annotation attributes: values on the method will override the values on the class. Since 6.13 you can use |
Copied from http://code.google.com/p/testng/issues/detail?id=102
Tested with TestNG 6.3.1 too
What steps will reproduce the problem?
I have a test class like this:
@test(enabled = false)
public class MyTest {
@dataProvider(name = "bla")
private Object[][] bla() {
return new Object[][] {
new Object[] { "bla"}
};
}
@test(dataProvider = "bla")
public void blatest(String bla) {
System.out.println(bla);
}
}
What is the expected output? What do you see instead?
I would expect method blatest not to run and no console output. Instead blatest runs and prints "bla".
What version of the product are you using? On what operating system?
I've tested with testng 5.11/6.0.1, running from maven 2.2.1/3.0.3 with surefire plugin 2.7.2.
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: