-
Notifications
You must be signed in to change notification settings - Fork 29
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
Cornichon session is not shared amongst sequential scenarios #189
Comments
Dear maintainers, until you're not replying, I will just apply the following workaround package object mytester {
val hackmap = scala.collection.mutable.HashMap.empty[String, String]
}
// ------------
package mytester
class MyFeature extends CornichonFeature {
afterEachScenario {
Attach {
And I EffectStep.fromSync(
title = "push Cornichon session to next scenario",
effect = { session =>
session.content.foreach {
case (key, values) => hackmap += key -> values.last
}
session
}
)
}
}
beforeEachScenario {
Attach {
Given I EffectStep.fromSync(
title = "pull Cornichon session from previous scenario",
effect = { session =>
hackmap
.foldLeft(session) {
case (session, (key, value)) =>
session.addValueUnsafe(key, value)
}
}
)
}
}
// scenarios go here ...
} I'm sorry it looks like an ugly hack, but it gives me a way not to get stuck ... can you advice for a more elegant solution, please? |
I think cornichon follows the rule that is common sense in BDD. E.g. |
Hi @angiolep, Having one Not only it allows parallel execution of the Each You mentioned the There are 4 different hooks available for you to work with:
According to your comment, I can see that you have already found 2) and 3). The problem with 1) and 4) for the moment is that they are no Sadly it is not straight forward to implement in May I ask you what kind of pre-setup you are trying to perform? Maybe we can find a way to encode it with the existing hooks or maybe I could perform small changes to enable your use case. I hope I was able to clear things up for you. |
FYI this issue is likely to be closed soon due to inactivity. |
Hi maintainers,
I do not know if it's a defect or a deliberate design but I noticed a Cornichon session does not outlive scenarios. In other words, it seems to me that the Cornichon session lifecycle coincides with its scenario lifecycle and, therefore, it does not span over the next scenario.
Is it a deliberate design because the author wanted to support execution of scenarios in parallel?
I rather wish to implement a feature made of a sequence of two scenarios (one after the other) and therefore, by reading the Cornichon documentation, I understood I shall set the following in the
application.conf
file:But, when I tried to execute:
Unexpectedly, the second scenario runs with an empty Cornichon session ( ... mmhhh ... )
I wrote my test the way described above because I wish the first scenario produce a value into the Cornichon session and thereafter the second scenario reuse it ... but ... it seems that each scenario works with its own Cornichon session.
Is there any way to make sequential scenario share the very same Cornichon session, please?
I'm asking for it because, in the world of test engineering is pretty common to reuse the test fixture (think about the "state of the sytem under test") left over by the previous test case. Reusing fixture is referred as the "shared fixture pattern" which I have not been able to apply with Cornichon.
The text was updated successfully, but these errors were encountered: