-
Notifications
You must be signed in to change notification settings - Fork 29
MemberResourceTest.java's memberResource is NOT Always Assigned #192
Comments
@jamesrdf, how are you running the tests? I only see one MemberResourceTest instance getting created. I tried in Eclipse using the TestNG plugin and on the command line. |
From the command line: 49 Skips (including all MemberResource) using the master branch. java version "1.7.0_65" |
Results are not always consistent, sometimes master branch works sometimes it doesn't. |
@jamesrdf, the problem in the Stack Overflow post is @BeforeSuite annotation is on a method in a shared parent class. That's not the case with MemberResourceTest.setup(). I'm not saying there isn't a problem, but I'm not convinced we have it right. For what it's worth, I get consistent results running against my server. java -jar target/ldp-testsuite-0.2.0-SNAPSHOT-shaded.jar --server http://ldpjs.mybluemix.net/r/bc --basic Are you sure that the POST request isn't sometimes failing and sometimes succeeding against your server? Maybe running the indirect container tests first changes the result? |
With the patch the results are very consistent. Wireshark reveals no unexpected failed POST responses. |
After further testing it appears that the setup method is sometimes not called (at all) in the test suite. |
@jamesrdf I can reproduce against my server if I switch to --indirect. The setup() method never gets called. |
It seems that if I remove the tests marked "enabled = false" from IndirectContainerTest, MemberResourceTest.setup() is called again. @jamesrdf, can you confirm that works for you as well? |
Sometimes it is still not being called when those tests are removed, but perhaps failing less frequently. |
I think the problem is that these methods override a super class that is common to both the container and member tests. Test-NG might something think they were already called (when it invoked LdpTest#setup on the IndirectContainerTest instance). If I rename the setup tearDown methods to a unique name, I get (the desired) consistent results. |
- Only set static variables from LdpTest setup. Setup is only called once even when several classes inherit from LdpTest. - Change setup and tear down method names so we don't accidentally override them in subclasses. See testng-team/testng#313 Fixes w3c#192
- Only set static variables from LdpTest setup. Setup is only called once even when several classes inherit from LdpTest. - Change setup and tear down method names so we don't accidentally override them in subclasses. See testng-team/testng#313 Fixes w3c#192
The @BeforeSuite needs to be replaced with @BeforeTest or used with a static method.
When running a test suite many of the MemberResourceTest tests are incorrectly skipped. This incorrect behaviour is caused because many test instances have memberResource set to null and never run the setup/tearDown methods. Because of the @BeforeSuite annotation on the setup method, it is only run on a single test instance (that might not be reused) and all other MemberResourceTest instances are then skipped. Either memberResource should be changed to a static variable (so all MemberResourceTest instances share the same value) or the annotation should be changed to @BeforeTest, so each instance gets it own value.
The text was updated successfully, but these errors were encountered: