enhancement Failure

User tests: Successful: Unsuccessful:

avatar elkuku
elkuku
22 May 2014

One of the latest PHPStorm EAP releases contained "initial support" for Behat which, in conjunction with Mink, can be used to write automated tests.
I had not heard of Behat before but it immediately caught my attention because of the way tests are written in natural language -- Like this:

  Scenario: Check the top menu "Users"
    Given I am on "/"
    And I follow "Users"
    Then I should see "Users List"

This is the whole test. Human readable. No code involved.

Since our test suite is not very extensive currently -- maybe we can explore this a bit.

I also added a method to login a dummy user or a dummy admin for testing purpose. This functionality should only be available in a "local" environment.

Not sure how/if it can be run on Travis. I remember there was the possibility to start some kind of HTTP server?

There is also support for Selenium2 - just prefix a feature with @javascript and fire up the Selenium server.

This is meant as a start ?

See also: Testing Documentation

avatar elkuku elkuku - open - 22 May 2014
avatar mbabker
mbabker - comment - 22 May 2014

Apache server setup/startup can be found in the HTTP Package.

Cool idea :-)

avatar b2z
b2z - comment - 22 May 2014

Interesting. But I still do not completely understand - to make this work we do not need to write any code?

What I do not like personally is that we should mess our production code with the testing code (for example Local login controller).

avatar HermanPeeren
HermanPeeren - comment - 22 May 2014

Hey man, we are really on one line: Behat is also part of my presentation next week on JAB. Gave a presentation about it 2 weeks ago at 010php; some slides the same as on JAB, see http://www.slideshare.net/HermanPeeren/behat-34469545

Behat automatically generates tests from that format in which some steps have to be filled in by us, the programmers. Some common step definitions can be put together in a collection. Like for instance for Drupal: https://drupal.org/project/drupalextension . Also see this nice intro-video by Lin Clark: http://lin-clark.com/blog/2013/11/26/quickstart-testing-with-behat-mink-selenium/

avatar HermanPeeren
HermanPeeren - comment - 22 May 2014

The main advantages I see with BDD (Behavioral Driven Depevepment) with Behat:

  • test formulation stays close to the domain language and can be made by / shared with non-techies
  • it fits well in an Agile workflow of Red-Green-Refactor
  • The implemented features are Use Cases / User Stories, as normally used in Agile development
  • it is aimed at defining concrete features and keeps the techies focussed on delivering valuable software instead of on underlying technique, databases or whatsoever

What I also like of Mink: you do not always need a complete Selenium browser emulation, which makes the test take very long (Javier told me it takes half a day, if I remember well, to do all Selenium tests for the Joomla CMS). When you don't use Javascript, you can also use a so called headless browser, like Goutte. Mink is a layer around those different browser emulations.

Codeception is another PHP framework for BDD. It can be used from PHP. That is easier for developers, but I personally think it is better to use domain language as much as possible. But an advantage of Codeception is also that it can be used for the PHPUnit-tests as well, once you are implementing on the class-level. Things can be combined. Also see this book: http://www.manning.com/smart/

avatar elkuku
elkuku - comment - 30 May 2014
avatar elkuku elkuku - change - 15 Jul 2014
Description <p>One of the latest <a href="http://blog.jetbrains.com/phpstorm/2014/05/phpstorm-8-eap-138-184/">PHPStorm EAP releases</a> contained "initial support" for <a href="http://behat.org/">Behat</a> which, in conjunction with <a href="http://mink.behat.org/">Mink</a>, can be used to write automated tests. <br> I had not heard of Behat before but it immediately caught my attention because of the way tests are written in natural language -- Like this:</p> <pre><code> Scenario: Check the top menu "Users" Given I am on "/" And I follow "Users" Then I should see "Users List" </code></pre> <p>This is the whole test. Human readable. No code involved.</p> <p>Since our test suite is not very extensive currently -- maybe we can explore this a bit.</p> <p>I also added a method to login a dummy user or a dummy admin for testing purpose. This functionality should only be available in a "local" environment.</p> <p>Not sure how/if it can be run on Travis. I remember there was the possibility to start some kind of HTTP server?</p> <p>There is also support for <a href="http://docs.seleniumhq.org/">Selenium2</a> - just prefix a feature with <code>@javascript</code> and fire up the Selenium server.</p> <p>This is meant as a start <img class="emoji" title=":wink:" alt=":wink:" src="https://assets-cdn.github.com/images/icons/emoji/wink.png" height="20" width="20" align="absmiddle"></p> <p>See also: <a href="https://github.com/joomla/jissues/blob/behat/Documentation/Development/Testing.md">Testing Documentation</a></p> <p>One of the latest <a href="http://blog.jetbrains.com/phpstorm/2014/05/phpstorm-8-eap-138-184/">PHPStorm EAP releases</a> contained "initial support" for <a href="http://behat.org/">Behat</a> which, in conjunction with <a href="http://mink.behat.org/">Mink</a>, can be used to write automated tests. <br> I had not heard of Behat before but it immediately caught my attention because of the way tests are written in natural language -- Like this:</p> <pre><code> Scenario: Check the top menu "Users" Given I am on "/" And I follow "Users" Then I should see "Users List" </code></pre> <p>This is the whole test. Human readable. No code involved.</p> <p>Since our test suite is not very extensive currently -- maybe we can explore this a bit.</p> <p>I also added a method to login a dummy user or a dummy admin for testing purpose. This functionality should only be available in a "local" environment.</p> <p>Not sure how/if it can be run on Travis. I remember there was the possibility to start some kind of HTTP server?</p> <p>There is also support for <a href="http://docs.seleniumhq.org/">Selenium2</a> - just prefix a feature with <code>@javascript</code> and fire up the Selenium server.</p> <p>This is meant as a start <img class="emoji" title=":wink:" alt=":wink:" src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f609.png" height="20" width="20" align="absmiddle"></p> <p>See also: <a href="https://github.com/joomla/jissues/blob/behat/Documentation/Development/Testing.md">Testing Documentation</a></p>
avatar javigomez
javigomez - comment - 17 Mar 2015

just crossreferencing for system testing. Similar pull but using Codeception instead of Behat/Mink joomla/joomla-cms#6463

Test are not that nice but human readable too: https://github.com/joomla/joomla-cms/pull/6463/files#diff-7392bf22f8e471d7cdd3253559928d2aR27

avatar mbabker
mbabker - comment - 12 Mar 2016

We need tests. Of everything. Can we do something with this?

avatar b2z
b2z - comment - 13 Mar 2016

We need a spare time for tests :( Codeception also is nice. Thanks @javigomez for JAB15 session ;) May be sometimes we will have a JTracker Tests Working Group? :+1:

avatar mbabker
mbabker - comment - 25 Mar 2016

Can't say I've done anything with Behat, but Codeception I've done a little bit with. The only "issue" with whatever platform gets used for tests around the UI is it's gotta be able to deal with our AJAX'd interface (which I think Codeception does, again don't know enough on Behat to comment there).

avatar elkuku elkuku - change - 29 Mar 2017
The description was changed
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-03-29 17:33:16
Closed_By elkuku
avatar elkuku elkuku - close - 29 Mar 2017
avatar elkuku elkuku - close - 29 Mar 2017
avatar elkuku elkuku - head_ref_deleted - 24 Jun 2018

Add a Comment

Login with GitHub to post a comment