|
||||
Orkney Demo |
Orkney comes with a small demo that contains some more test
groups and test cases. We will examine the directory and run the
tests to see more examples.
The Demo Tests are structured in directories representing the
test groups. Find below the full directory tree:
demo
└───work
├───input
└───tests
├───1BasicTests
│ ├───1StringTests
│ ├───2NumberTests
│ └───3MiscTests
└───2AdvancedTests
├───1XPathTests
└───2MiscTests
The directory input
contains test data, while directory tests holds all test groups and test cases written
in Yaml. Below the main test group tests we have two sub groups, 1BasicTests and 2AdvancedTests.
The basic tests are divided into string test examples, number
tests examples and some miscellaneous tests. Inside the string
test group there is a string test example case called StringTest.yaml. This case we
already know, we have introduced this example in Orkney's introduction page.
The test group for numbers shows an example of arithmetic tests.
A new Orkney feature is introduced for this test, the usage of
properties. Have a look to the test group directory 2NumberTests and note that
there a two files
IntegerTest.yaml
orkney.properties
The first one is the test case in this group, while the
properties file is used to set some global variables for all test
cases inside the group. Whenever you define a test group you can
define global parameters. Do this simply by creating a new
properties file inside the directory and name it orkney.properties. The
variables that is the properties you define, will be available
inside each test case of this group or its sub-groups.
Lets see how this works, the properties file defines two
variables
orkney.properties
intnumber1=1234
intnumber2=4321
that are used inside the test script
IntegerTest.yaml
description: Testcase for simple integer arithmetic
steps:
- step: de.softquadrat.orkney.steps.number.IntegerAdd
in: { i1: $intnumber1, i2: $intnumber2 }
out: { sum: $val }
- step: de.softquadrat.orkney.steps.number.IntegerCompare
in: { i1: $val, i2: 5555 }
Note that the two variables intnumber1
and intnumber2 (coloured
in blue) are referenced inside the test case for reading like
other variables. You can use this feature for several purposes,
typically you can define user and passwords globally in order to
maintain them at one place only for all your tests. Another use
case are host names, ports or url ou can define once and read
everywhere.
And finally the test group inside the basic tests shows two
failing tests. The first one is called FailingTest1.yaml, this test case fails due to a
step named Fail. This test step will alway fail and can be used to
force unsuccessful test cases. The other failing test is called FailingTest2.yaml. This test
script contains a wrong Yaml script using tabs instead of spaces.
And the last basic test demonstrate the usage of a test step
writing a text file.
The advanced tests demonstrate the usage of XPath steps, an
example XML file is read from the test data directory input. The GetByXPathTest.yaml shows how
to select a node content using an XPath expression. The second
example SetByXPathTest.yaml
uses XPaths expressions to set and get the text content of a node.
GetByXPathTest.yaml
description: Testcase Reading Node Text in XML using XPath
steps:
- step: de.softquadrat.orkney.steps.fileio.ReadTextFile
description: Read Text File
in: { filename: test.xml } out: { content: $xml }
- step: de.softquadrat.orkney.steps.xml.GetNodeContentByXPath
description: Get Node Value By XPath
in: { inxml: $xml, xpath: /root/subnode } out: { out: $value }
- step: de.softquadrat.orkney.steps.strings.PrintString
description: Print String Value
in: { sin: $value }
The advanced test group also contains two more test case in the
group 2MiscTests. The
first of them called EmptyTest.yaml
just shows that empty test scripts are allowed (just in case you
require ;). The other one GenerateUidTest.yaml
explains the usage of a test step that generates a unique id.
You can run the demo by simply invoking the start script
runOrkney.sh -w demo/work *(for Unix)* runOrkney.cmd -w demo\work *(for Windows)*
Note the option -w followed by the working directory. Without
this option Orkney would seek for a directoy work with test data and test
cases.
The resulting output of the invocation will give
./runOrkney.sh -w demo/work/Again open the XML report and examine the test results ...
Orkney, version 0.0.2
Copyright (c) 2013, 2014 SoftQuadrat Gmbh
Orkney test run completed with result: Fail.
9 tests executed.
7 tests run successfully.
2 tests failed.
Note: A full report showing the results of executing the Orkney demo project can be found here. Open it and try to navigate through the test results of the demo in order to understand their structure and the navigation. |
⇐ Welcome to Orkney! |
Navigation |
⇒ Orkney Invocation |