Comments (9)
It's a feature. When using shared session strategy the cookies are shared between all tests in a test case. This allows to have complex test cases, that are combined of several commonly used tests (e.g. testLogin
, testAddProductToCart
, testPayWithCreditCard
). If one of tests failed, then possibly there are some left-overs in the browser that might interfere with other tests. For that reason browser window is closed.
What you though (not sure if I've explained that in docs) the shared session strategy is for?
from phpunit-mink.
I know what the shared session strategy is for, I just thougt that the tab isn't closed if one test fails. Is there any other way than calling $session->visit() in every test? I'm just searching for different strings, but don't want them to be in just one test.
Thanks for the fast answer!
from phpunit-mink.
@luklapp be careful that it is possible to have tests running without running the others. If they depend on the outcome of the previous test, you should use the @depend
feature of PHPUnit, which will skip the second test if the first one failed, recognizing that it depends on the work done in the first one
from phpunit-mink.
Failing test is bad in any case, so if window/tab is closed, that shouldn't bother anybody really.
Also one thing about @depends
annotation: the tests that use it must be declared below ones, that they depend upon. This is technical limitation of PHPUnit.
Now, once @stof mentioned @depends
annotation this kind of defeats the purpose of shared session strategy all together, because you need to manually specify which tests require which other test(-s) to pass to ensure specific test execution order. In contract in Behat you got the chain automatically by defining scenario. But what's bad in Behat is that you've got feature file as a mix of totally unrelated steps which turns out maintenance of the tests into a nightmare.
from phpunit-mink.
@stof @aik099 Thanks for clarification. They don't depend on each other, they search just different strings, but on the same page (without any interaction). Should I put them in the same test, altough I am testing different things? It's possible that one test fails, but the others are working.
from phpunit-mink.
If test structure is similar, then I tend to have 1 test + specify all strings via data provider method.
from phpunit-mink.
OK, thanks for support!
from phpunit-mink.
@aik099 Behat will still reset sessions. It will simply do a soft-reset rather than a hard reset. It does not share the session state between scenarios (and this would be rejected as Behat considers that scenarios are meant to be fully isolated).
And if the test relies on the state generated by the previous one, it is precisely the use case for @depends
from phpunit-mink.
Behat will still reset sessions. It will simply do a soft-reset rather than a hard reset.
Yeah, I know and that's cool. I'm also planning to switch to soft reset permanently (at some point in #5) or make it configurable, but I'm not sure how to technically implement that knowing architecture of the library.
And if the test relies on the state generated by the previous one, it is precisely the use case for
@depends
Then all is fine and works as expected. That's good to know.
from phpunit-mink.
Related Issues (20)
- PSR-2 coding standard compatibility HOT 5
- Grant Packagist App access to repository HOT 5
- CI needs to be migrated to GitHub Actions HOT 2
- Create proxy around Mink's Session
- Switching to 1st opened window in shared session strategy doesn't work HOT 8
- Create CHANGELOG.md file HOT 3
- Failed to use shared session strategy HOT 1
- The "SuiteBuildingTest::testSuiteTearDown" fails on PHPUnit 4.6+
- Some tests are marked as risky HOT 3
- Implemement PhantomJs Driver Factory HOT 8
- Include "@throws" in "createDriver" method of driver factories HOT 1
- Notice, when used with PHPUnit 5 HOT 13
- Change links to ReadTheDocs to IO domain
- Fix tests on HHVM HOT 1
- Session doesn't work with Selenium2 driver HOT 6
- Backport each fix into earlier releases HOT 6
- Why do I have to set PHPUNIT_MINK_TUNNEL_ID as environment variable? HOT 3
- PHPUnit 6 compatiblity HOT 22
- Call to a member function getDefaultSessionStrategy() on null HOT 7
- Argument 1 passed to BrowserTestCase::onNotSuccessfulTestCompatibilized() must be an instance of Exception HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpunit-mink.