I am currently working on a Laravel CRUD application and I was wondering why PHPUnit does not support crawling the browser (anymore, as I read). I already covered the basement of my project via PHPUnit, but I do also want to test links, a tags, button clicks etc. So I do already have a strong basement of unit tests.
Now I read about Dusk providing a crawler for DOM tests. Shall I use both together (is it even possible?) or should I migrate to Dusk? I'm not sure whether Dusk provides the same functionality as PHPUnit does and as stated, I do already have a strong phpunit testing base.
From now on I'm kinda stuck, because of 50:50 testcases, as I do also need to test whether the DOM does provide the correct information.
Appreciate any help or expert advice.
Thank you in advance!
Dusk is not a crawler but a browser driver, it can control a (headless) browser.
Specifically designed on top of PHPunit to do E2E (end to end) testing.
So convert to Dusk what is browser tests (html/javascript), but everything else keep as unit tests.
API tests for example you don't need dusk at all.
Related
I have a suite of cypress tests for an online application. Some of my tests only tests what is on the final page of the application or decision pages and hence do not want to always fill the initial pages each time I run these tests. I am hence trying to see if I can load state and which auto populates all the initial pages and loads the page I have the tests or require to test
I tried using cy.session like in the login scenario but not making headway with this.
Please does anyone know how this can be done.
I am trying to write a functional test using codeception for Laravel 5. Fails to validate elements loaded by JS. How do I wait for all JS to be run and the page to be fully loaded. It this achievable?
You should use Selenium for this. Laravel has Selenium support out of the box (though you'll still need to download the Selenium standalone server and have Java installed)
We have client-side validation and server-side validation as a back up in this Laravel application, and we want to test both, but I can't figure out if that's possible. Is it possible to turn off JavaScript for a single run of the tests, then run them again with it on using Codeception?
Test with PhpBrowser or Laravel5 module.
They can't execute Javascript, so only server side validation is possible.
You will have to create a separate test suite (or use functional if you aren't using it yet) for these tests, because you can have only one of WebDriver, PhpBrowser and Laravel5 modules enabled at a time.
We are toying with Behat to start writing specifications for our PHP applications. All step definition implementation examples are for plain PHP classes, but we are using CodeIgniter as a our prefered framework.
We rule out writing features and scenarios that are UX/UI oriented (that would abstract away the underlying framework) until later in the development stage, and would like instead to test the application layer by accessing the CodeIgniter models.
How do you get Behat to use these models? i.e. how do you integrate Behat with CI?
Download here Behat CI Test
Simple test with Behat and CodeIgniter. The CodeIgniter controller just displays a login page and returns a data array that use to make assertions. There are various debug statements printed with error_log, which Behat displays on stdout, to follow the flow of execution.
I am using merb with rspec and webrat. How to ensure that rjs template was successfully rendered? I cannot just write have_xpath because of ajax.
This is not easy. You already mention selenium, which will test from the browser all the way down, but it is slow. My suggestion is to break this into a couple parts. First use rspec to check the output of both the original page request to make sure it has the JavaScript you think it does, and also the ajax response to ensure that it is being served correctly.
Now the trick is to test the JavaScript itself. There are a number of testing libraries for JavaScript. I suggest jUnit. write tests just like you would for rspec and test the function of your ajax request, and the resultant rjs separately.
Finally use selenium to run the full stack and prove everything works together. If there are bugs go back to one of your unit test and write a simpler test that will expose the bug.
Well, I got it. There are selenium, watir and friends. Sounds weird because I need a browser for testing :(