-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
State not reset between tests when using Test Orchestrator #56
Comments
Could you please submit your changes as a pull request against this repo? That way we can inspect the diff to see what you have changed. |
Sure thing, I've updated the description with a link. |
@patjackson52 This state in your case is static field. To clear static field the classloader should be killed and created new one. cucumber has nothing to do with static fields and even discourages to use ones. I don't use orchestrator so I'm not expert in it. Are you sure that the same case works with basic |
@lsuski Test Orchestrator will run each test in its own process. All memory is like a fresh launch when using Test Orchestrator. Yes, I have confirmed this works with I attempted using the AndroidJunitRunner with the cukelator example and no tests were found. This would be a great feature to have to be able to clear state between scenarios. I'm going to look into the code and see if I can see what is going on. If you, or anyone, is interested in pairing or sharing knowledge please ping me. |
@lsuski Actually appears cucumber-android does not use test orchestrator at all, at least with the config in my repro example. The test orchestrator process does not run on the test device when using my repro example. I have been able to clear state between tests however.. Spoon supports this with the `singleInstrumentationCall = false" option. Appears Spoon does not work with Test Orchestrator, and instead has its own method of running isolated instances of the app for each test. If I'm correct in that Test Orchestrator does not work with cucumber-android, the readme should be updated. It states in the first paragraph that it DOES support orchestrator. A better wording would be "supports sharding via Spoon" If someone confirms the above, I would gladly make a PR for updating documentation about Test Orchestrator, Spoon, and reseting state between tests. |
Hello @patjackson52 , Android Test Orchestrator does not work with Spoon, but it works perfectly fine without it, so the claim that it "DOES support Test Orchestrator" is perfectly valid😃. Probably it should be configured differently or fixed by Spoon. Best regards, |
WhenclearPackageData: true
is set and the Test Orchestrator is used, state should not persist between Scenarios.State is not reset between tests when using test orchestrator.
Note: Originally I thought
clearPackageData: true
must be set for state to be reset with Test Orchestrator. Apparently that is the default behavior, andclearPackageData
deals with file system (shared prefs, DB, etc)How to reproduce:
A branch with failing tests are here: #57
Run tests with
./gradlew runInstrumentationTests
and observe failures.Changes were made to the cukelator example where a static field is set on first run of
MainActivity.onCreate()
. If the flag is set in subsequent tests, it finishes the activity and fails the test.Commented settings in build.gradle were uncommented to enable Orchestrator and clearPackageData.
As a sanity check I completed the same test on the testing-samples calculator tests. This PR shows code that pass the tests.
patjackson52/testing-samples#1
The text was updated successfully, but these errors were encountered: