-
-
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
Testing reusable composables without activity not possible #102
Comments
I've debugged your project and it looks like
It looks like in cucumber this event is sent after rule |
For now I see that it can be disabled:
|
Thanks for the quick reply. May I ask how you found out this was the problem? Was it just experience or did I overlook something? I have put breakpoints on the constructor and methods of In general, you'd want to wait for activities from previous tests to complete before starting a new one, so I'm not sure disabling it is the way to go. However, apparently it should default to false at some point in the future. I'll try that. I'll also have a quick try, provided I have some time, to see if some hacking to switch the event order and rule execution resolves the issue. Also I'll try to check the order JUnit runs it. |
What I've done was:
As you can see in TODO they will eventually change this behaviour. After each test there is |
Your test fails now because it's expects wrong texts |
Use this:
and this
|
Regarding implementation change it is probably possible to change the order and to run rules |
I never got to debugging the actual test cases, but thanks for the heads-up. I have debugged the rule and activity finisher under "normal" JUnit conditions, and there the test started event fires before the rule is executed. A more future-proof solution would be, in my opinion, to see if Cucumber Android can use JUnit rules in a similar way to JUnit itself. Then we're not making things work by addressing the symptom (which is fine in the short-term, don't get me wrong) but actually improving the situation for all possible rules out there. Rule developers do make assumptions, as clearly illustrated by this example. As mentioned I'll see if I can make a proof-of-concept and submit it as a PR. No promises though, this scenario is relevant for me but I'm also quite busy, so I do understand. |
Cucumber has different engine. There is no support for junit rules. Junit rule is some kind of wrapper, in Cucumber you have before/after hooks. Without significant changes in cucumber-core/junit it won't be possible to do that. I don't want also to copy lots of thing from cucumber-jvm repo |
👓 What did you see?
When using a
ComposeContentTestRule
(created withcreateComposeRule()
) in order to test a reusable composable without an activity, the test activity finishes before the test has completed (or even started). The test fails with an exception indicating the activity has already been destroyed.A detailed description and example can be found in the README of the project referenced below.
✅ What did you expect to see?
The activity is only destroyed at the end of the test. The test passes.
📦 Which tool/library version are you using?
Detailed versions can be found in the
build.gradle
file of the project referenced below.🔬 How could we reproduce it?
@WithJUnitRule
containing a compose rule created withcreateComposeRule()
setContent
on the compose rule, setting a composable (for example some text)Project demonstrating the issue: https://github.com/jjkester/cucumber-compose
📚 Any additional context?
In the README of the project referenced above I have detailed my observations, including the debugging effort I went through and what I could observe/conclude from that.
This text was originally generated from a template, then edited by hand. You can modify the template here.
The text was updated successfully, but these errors were encountered: