Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

MemberResourceTest.java's memberResource is NOT Always Assigned #192

Closed
catch-point opened this issue Oct 6, 2014 · 11 comments · Fixed by #202
Closed

MemberResourceTest.java's memberResource is NOT Always Assigned #192

catch-point opened this issue Oct 6, 2014 · 11 comments · Fixed by #202

Comments

@catch-point
Copy link
Contributor

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.

@spadgett
Copy link
Contributor

spadgett commented Oct 6, 2014

@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.

@catch-point
Copy link
Contributor Author

From the command line:
$ mvn clean package
$ java -jar target/ldp-testsuite-0.2.0-SNAPSHOT-shaded.jar --indirect --server 'http://localhost:8080/ldp/?describe'

49 Skips (including all MemberResource) using the master branch.
28 Skips when I change the annotations to @BeforeTest/@AfterTest and reset memberResource to null in the tearDown.

java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-3~14.04)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

@catch-point
Copy link
Contributor Author

Results are not always consistent, sometimes master branch works sometimes it doesn't.

@catch-point
Copy link
Contributor Author

@spadgett
Copy link
Contributor

spadgett commented Oct 6, 2014

@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?

@catch-point
Copy link
Contributor Author

With the patch the results are very consistent.

Wireshark reveals no unexpected failed POST responses.

@catch-point
Copy link
Contributor Author

After further testing it appears that the setup method is sometimes not called (at all) in the test suite.

@spadgett
Copy link
Contributor

spadgett commented Oct 6, 2014

@jamesrdf I can reproduce against my server if I switch to --indirect. The setup() method never gets called.

@spadgett
Copy link
Contributor

spadgett commented Oct 6, 2014

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?

@catch-point
Copy link
Contributor Author

Sometimes it is still not being called when those tests are removed, but perhaps failing less frequently.

@catch-point
Copy link
Contributor Author

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.

spadgett pushed a commit to spadgett/ldp-testsuite that referenced this issue Oct 7, 2014
- 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
spadgett pushed a commit to spadgett/ldp-testsuite that referenced this issue Oct 7, 2014
- 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants