How to inherit previous settings throughout your automated test suite?

Wouldn’t it be nice, if you could let all (most) test <steps> inherit some of your test assertions?

So for example, wouldn’t it be nice, if you could specify that all of your <urls> result in a <status>200</status> and none of your URLs result in a <notstatus>500</notstatus>.

The inheritance feature of our automated website test tool allows you to do exactly that:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite xmlns:xi="http://www.w3.org/2001/XInclude">
    <inherit>
        <status>200</status>
        <status>301</status>
        <status>302</status>
        <status>303</status>
        <notstatus>404</notstatus>
        <notstatus>500</notstatus>
        <notcontains><![CDATA[<b>Fatal error</b>:]]></notcontains>
        <notcontains><![CDATA[<b>Notice</b>:]]></notcontains>
        <notcontains><![CDATA[<b>Parse error</b>:]]></notcontains>
        <notcontains><![CDATA[<b>Warning</b>:]]></notcontains>
    </inherit>
    <userstory title="Test your application URLs for common error message strings caused by server-sided scripting and/or bad HTTP codes">
        <scenario title="A list of all the URLs of your web application">
            <step>
                <url>http://automateyourtests.com/demo_application/</url>
            </step>
            <step>
                <url>http://automateyourtests.com/demo_application/</url>
            </step>
            <step>
                <url>http://automateyourtests.com/demo_application/</url>
            </step>
            <step>
                <url>http://automateyourtests.com/demo_application/</url>
            </step>
        </scenario>
    </userstory>
</testsuite>

The following test config examples show you what other inheritance is possible.

You are able to inherit the following nodes either across your whole <testsuite> or, alternatively, just across the <steps> in some selected <userstory> or <scenario> nodes.

How you can <inherit> a common login user across a series of <steps>?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <logins title="Let each test step execute in the context of an authenticated user" cookiedir="{TEMPDIR}">
        <user label="Homer Simpson">
            <url>http://automateyourtests.com/demo_application/wp-login.php?testcookie=1</url>
            <post><![CDATA[log=homer&pwd=doh]]></post>
            <notcontains><![CDATA[<div id="login_error">]]></notcontains>
        </user>
    </logins>
    <userstory title="Test that the login user 'Homer Simpson' gets inherited by every 'step' in this 'userstory'">
        <inherit>
            <user>Homer Simpson</user>
        </inherit>
        <scenario>
            <step>
                <url>http://automateyourtests.com/demo_application/wp-admin/</url>
                <contains>Howdy, Homer Simpson</contains>
            </step>
            <step>
                <url>http://automateyourtests.com/demo_application/wp-admin/</url>
                <contains>Howdy, Homer Simpson</contains>
            </step>
        </scenario>
    </userstory>
</testsuite>

How <url> inheritance works?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <inherit>
        <url>http://automateyourtests.com/demo_application/</url>
    </inherit>
    <userstory title="Show how to inherit a common 'url' throughout your test steps">
        <scenario>
            <step title="This tests the 'url' from above because of inheritance">
                <contains>Welcome to WordPress</contains>
            </step>
            <step title="This also tests the 'url' from above because of inheritance">
                <contains>Proudly powered by WordPress</contains>
            </step>
        </scenario>
    </userstory>
</testsuite>

Here a useful extension of <url> inheritance:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <inherit>
        <baseurl>http://automateyourtests.com/demo_application</baseurl>
    </inherit>
    <userstory title="The following 'url' gets prepended with the 'baseurl' from above">
        <scenario>
            <step>
                <url>/</url>
                <contains>Welcome to WordPress</contains>
            </step>
        </scenario>
    </userstory>
</testsuite>

And here an even more useful variation of <url> inheritance:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <userstory title="The following 'url' gets prepended with the 'baseurl' from the command line argument above">
        <scenario>
            <step>
                <url>/</url>
                <contains>Welcome to WordPress</contains>
            </step>
        </scenario>
    </userstory>
</testsuite>

Anyway, back to our examples.

How <post> data inheritance works?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <userstory title="Show how to inherit common 'post' data throughout your test steps">
        <inherit>
            <post><![CDATA[comment=Test+Comment&comment_post_ID=1]]></post>
        </inherit>
        <scenario>
            <step title="This submits the 'post' test data from above because of inheritance">
                <url>http://automateyourtests.com/demo_application/wp-comments-post.php</url>
            </step>
            <step title="This ALSO submits the 'post' test data from above because of inheritance">
                <url>http://automateyourtests.com/demo_application/wp-comments-post.php</url>
            </step>
        </scenario>
    </userstory>
</testsuite>

How <contains> test assertion inheritance works?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <inherit>
        <contains>Welcome to WordPress</contains>
    </inherit>
    <userstory title="This tests for 'Welcome to WordPress', 'Proudly powered by WordPress' and 'Just another WordPress site' because of inheritance">
        <inherit>
            <contains>Proudly powered by WordPress</contains>
        </inherit>
        <scenario>
            <step>
                <url>http://automateyourtests.com/demo_application/</url>
                <contains>Just another WordPress site</contains>
            </step>
        </scenario>
    </userstory>
</testsuite>

How <notcontains> test assertion inheritance works?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <inherit>
        <notcontains>Welcome to Joomla</notcontains>
    </inherit>
    <userstory title="This tests for 'Welcome to Joomla' and 'Proudly powered by Drupal' NOT to be on the web page because of inheritance (logical and)">
        <scenario>
            <step>
                <url>http://automateyourtests.com/demo_application/</url>
                <notcontains>Proudly powered by Drupal</notcontains>
            </step>
        </scenario>
    </userstory>
</testsuite>

How <status> test assertion inheritance works?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <inherit>
        <status>200</status>
        <status>301</status>
    </inherit>
    <userstory title="Show how to test for a URL to have some HTTP 'status' through inheritance">
        <scenario>
            <step title="This tests for a HTTP status code of 200 or 301 because of inheritance (logical or)">
                <url>http://automateyourtests.com/demo_application/</url>
            </step>
            <step title="This also tests for the same thing because of inheritance">
                <url>http://automateyourtests.com/demo_application/uncategorized/hello-world</url>
            </step>
        </scenario>
    </userstory>
</testsuite>

How <notstatus> test assertion inheritance works?

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite>
    <inherit>
        <notstatus>404</notstatus>
        <notstatus>500</notstatus>
    </inherit>
    <userstory title="Show how to test for a URL NOT to have some HTTP 'status' through inheritance">
        <scenario>
            <step title="This tests for a HTTP status code of 404 and 500 NOT to be returned because of inheritance (logical and)">
                <url>http://automateyourtests.com/demo_application/</url>
            </step>
            <step title="This also tests for the same thing because of inheritance">
                <url>http://automateyourtests.com/demo_application/uncategorized/hello-world</url>
            </step>
        </scenario>
    </userstory>
</testsuite>