Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
loadSessionSnapshot does not work with coverage enabled #2923
I have some working acceptance tests and am now trying to get code coverage for them. As recommended by the Guides, I use an @before directive to handle login before each test, and use saveSessionSnapshot to avoid having to go through login for each test.
This works nicely until I run codeception with --coverage. What happens then is that the first test in the file goes through nicely, but all subsequent tests, which rely on loadSessionSnapshot to skip login, do not work any more.
Is this behavior known?
I did some more digging, maybe someone with more experience with codeception can make sense of this. I am running
EDIT: Confirmed workaround for my issue is to explicitly set $I->amOnPage("whatever.php"); at the beginning of each test.
EDIT2: The culprit is in Codeception\Coverage\Subscriber\LocalServer (protected function startCoverageCollection) Line 151 which explicitly does
EDIT3: Ah, because we can only set cookies for the current domain. But why does it not return to the previous page then?
EDIT4: After some messing around, I think that moving
Thanks for the tips in this. I recently upgraded to 2.3.3 and implemented code coverage and saw my tests failing due to
Prior to this, I was depending on the order of tests of where they ended for the next one to begin. (Yes, I know that sounds horrible, that has been resolved).
@iBotPeaches strange, coverage cookies are ignored during when the snapshot is saved. See
Could you debug, is that so? If accidentally some coverage cookies are getting saved - that's the issue.
@DavertMik Maybe I don't understand this enough, but at my first request (ie login), I had no session so
Of course none of those were the
My lines didn't match up with the above link. I see 2.3.4 came out, so I might need to report back after I update.