Running WordPress Plugin Acceptance Tests on TravisCI – Typist Tech


We have written come acceptance tests in the last tutorial. Time to run them on the cloud. No way I would spend 10 minutes to wait for my tests ran for multiple PHP and WordPress versions. Continue from the last tutorial, I’ve removed some unused pieces and added PHP_CodeSniffer to the project. Nothing related to acceptance testing. Head over to the GitHub repo if you are interested.
A problem I found is that the tests failed randomly. The reason is that our tests tries to click some links before they show up on the screen. Adding $I->waitForElement(‘some element’, 10); solves the problem.
Secondly, when changing the screen size, the link
Acceptance Test for rmcl fails out of the screen. Adding
$I->click(‘Acceptance Test for rmcl’); solves it.
$I->amOnpage(‘/’);
$I->waitForElement(‘p.site-description’, 10);
$I->scrollTo([‘css’ => ‘h2.entry-title’]);
You can run the tests on real browsers on TravisCI with Sauce Labs. But it’s too slow for me. I opt for PhantomJS instead.
The Selenium server I used the last tutorial becomes buggy. I switched to use PhantomJS lately.
$ composer require –dev  jakoch/phantomjs-installer neronmoon/scriptsdev site5/phantoman
Source: https://managewp.org/articles/14567/running-wordpress-plugin-acceptance-tests-on-travisci-typist-tech


Source: https://williechiu40.wordpress.com/2017/03/12/running-wordpress-plugin-acceptance-tests-on-travisci-typist-tech/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s