testcases

  • CedThumbnails has been updated to version 2.6.0 and contains 4 new features and correct 1 bug for Joomla 2.5. For existing users the update will display in the Extensions Managerunder Updates. If you do not have this currently installed, you can click the link below and install like you are use to via the Extensions Manager.

  • apache_maven

    In a multi modules project where you have write API or common code for unit tests in one project and want to reuse these in the tests for another project. Maven will crash during the compile phase if you do not make the following.

    Maven rules of the game:

    • The main code in src/main/java is visible across modules if you did specify project
      dependencies in pom.xml.
    • Test code reside in src/test/java and is not shared across modules, moreover
    • Test code can use any code from src/main/java but not the other way around, which
      make sense as we want to clearly separate test code (junit testcases) from code shipped.

    The solution is to create additional test jar for each module, this is done by putting in the
    parent pom (lets call it parent-pom.xml)

    inside the <build></build> tags the following:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
    </plugin>

This will create for each modules an additional jar named {artifactId}-{version}-tests.jar
during the goal test-jar

Now for every modules where you want to reuse test classes, all you have to do in to put in every
modules pom.xml a dependency to that test jar by adding the tests classifier

 <dependency>
     <groupId>yourGroup</groupId>
     <artifactId>yourReusableModuleArtifact</artifactId>
     <version>0.1-SNAPSHOT</version>
     <classifier>tests</classifier>
     <scope>test</scope>
 </dependency>

 

This has work for me with Maven 2.0.8

  • open.qa.logo Selenium is a test tool for web applications. Selenium tests run directly in a browser, just like real users do. It runs in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh, Safari on the Mac.&160; They have plans to target Safari on the iPhone in some months. The tool is free and available under Apache 2.0.


    • Install the firefox plugin, note the latest version work only in Firefox 2.0 not in 3.0Beta!
    • Install also XPather another Firefox extension, very helpful to get the elements&160; XAPTH in pages.
    • Of course restart Firefox
    • Open either the sidebar (go to menu View, Sidebar, Selenium IDE) or the floating windows
      (go to menu Tools - Selenium IDE)
    • Go to the page where you wan to test something
    • Put the right Base URL (A) and press button (B) when ready
      doYourFirstSeleniumTest
    • You can now act like any user, enter data, change values, click on links
    • When You wan to add a check, you can at any time right click on a HTML element
      (a text, a cell, a button...) to see what selenium is proposing you.
      doYourFirstSeleniumTest.2
    • Not all possibility are proposed...so this is where knowing the element XPATH is helping...
      for more complex check, you can right click on any element and get the XPATH
      doYourFirstSeleniumTest.3 doYourFirstSeleniumTest.4
      now just cut and paste and feed the command (I choose verifytextPresent)
      doYourFirstSeleniumTest.5
    • Don't forget to stop the engine when you are finished or the script may be huge.
    • Into C, You can now cut and paste one or many lines, insert new commands (add more assert)
    • And replay seleniumSecurityImages2 till the&160; bar is green

    &160;

    Attention:

    • Do not abuse XPATH expression as it somehow hard code the previous position of the element in the page.
    • Try to make each test run on its own, do not expect that the test before is successful (so login. test functionality 1, logout)
    • Keep unit test small,
    • Keep all test in a repository (CVS or SVN) or many backup.

    Read also:

  • Since I did not find any clear how to on the internet how to run test cases for 3rd party extensions that use Joomla CMS, here is my version of it.

    Prerequisites

    Having PHPUnit properly install, if you use XAMPP you may want to read this post.

     

    How to use PHPUnit in Joomla

    At the root of your Joomla installation directory, make a checkout of https://github.com/joomla/joomla-cms/tree/master/tests/unit

    You’ll need at least the following file

    • ${joomla_root}\tests\unit\bootstrap.php
    • ${joomla_root}\tests\unit\config.php
    • ${joomla_root}\tests\unit\JoomlaDatabaseTestCase.php
    • ${joomla_root}\tests\unit\JoomlaTestCase.php
    • ${joomla_root}\tests\unit\phpunit.xml
    • ${joomla_root}\tests\unit\readme.txt

    config.php is a custom or a copy of your configuration.php

    For your convenience, I provide a zip file (joomla_phpunit_testing.zip), unpack in your Joomla root and you’re done.

    Note when using PHPUnit 3.6 , Joomla should not need to include/require anything PHPUnit related since (at least) PHPUnit 3.6. This create errors otherwise.

    In PHPStorm

    Set Up PHPUnit

    Go to Settings, using CTRL+ALT+S, under PHPUnit, select the option “Use Bootstrap file” and use as value ${joomla_root}\tests\unit\bootstrap.php

    Set Up PHPUnit Skeleton Generator

    Go to Settings, using CTRL+ALT+S, under “Skeleton Generator”

    • Enter for “Path to phpunit-skelgen” the value is  ${xampp_root}\php, for example C:\xampp\php
    • Enter for “use bootstrap file” the value ${joomla_root}\tests\unit\phpunit.xml

    Your first Joomla test case

    Create a test case from any of your Joomla classes, by hitting CTRL+SHIFT+T, this will let you select the method you want to test and generate a runnable albeit incomplete test classes.

    It is only the beginning of testing your Joomla extensions, there is a lot now to learn

    • Mocking objects in Joomla, Stubbing of Joomla classes
    • Invoking protected method using TestReflection::invoke
    • How to create integration tests using the database
    • How to test the user interface using PHPSelenium
    • and more…

    These links may interest you