Giter Club home page Giter Club logo

Comments (9)

aik099 avatar aik099 commented on August 22, 2024

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.

luklapp avatar luklapp commented on August 22, 2024

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.

stof avatar stof commented on August 22, 2024

@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.

aik099 avatar aik099 commented on August 22, 2024

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.

luklapp avatar luklapp commented on August 22, 2024

@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.

aik099 avatar aik099 commented on August 22, 2024

If test structure is similar, then I tend to have 1 test + specify all strings via data provider method.

from phpunit-mink.

luklapp avatar luklapp commented on August 22, 2024

OK, thanks for support!

from phpunit-mink.

stof avatar stof commented on August 22, 2024

@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.

aik099 avatar aik099 commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.