Source

Test Automation Framework / test-automation-framework / target / test-results / com / sqanta / testautomation / framework / TestData.html

<?xml version="1.0" encoding="UTF-8"?><html xmlns:c="http://www.concordion.org/2007/concordion">

<head><script type="text/javascript">
function show(id) {
  document.getElementById(id).style.visibility = 'visible';
}

function hide(id) {
  document.getElementById(id).style.visibility = 'hidden';
}
function showScreenshotOn(e) {
  var targ;
  if (!e) var e = window.event;
  if (e.target) targ = e.target
  else if (e.srcElement) targ = e.srcElement
  if (targ.nodeType == 3) // defeat Safari bug
    targ = targ.parentNode;
  if (targ.nodeName == 'P')
    targ = targ.parentNode;
  return (targ.className.indexOf('stackTrace') != 0);
}</script><style>
.screenshot {
  position:absolute;
  visibility:hidden;
  border:solid 1px black;
  z-index:30;
}
</style><style>* {
  font-family: Arial;
}
body {
  padding: 32px;  
}
pre {
  padding: 6px 28px 6px 28px;
  background-color: #E8EEF7;
}
pre, pre *, code, code *, kbd {
  font-family: Courier New, Courier;
  font-size: 10pt;
}
h1, h1 * {
  font-size: 24pt;	
}
p, td, th, li, .breadcrumbs {
  font-size: 10pt;
}
p, li {
  line-height: 140%;
}
table {
  border-collapse: collapse;
  empty-cells: show;
  margin: 8px 0px 8px 0px;
}
th, td {
  border: 1px solid black;
  padding: 3px;
}
td {
  background-color: white;
  vertical-align: top;
}
th {
  background-color: #C3D9FF;
}
li {
  margin-top: 6px;
  margin-bottom: 6px; 
}


.example {
  padding: 2px 12px 6px 12px;
  border: 1px solid #C3D9FF;
  margin: 6px 0px 28px 0px;
  background-color: #F5F9FD;
}
.example h3 {
  margin-top: 8px;
  margin-bottom: 8px;
  font-size: 12pt;
}

p.success {
  padding: 2px;
}
.success, .success * {
  background-color: #afa !important;
}
.success pre {
  background-color: #bbffbb;
}
.failure, .failure * {
  background-color: #ffb0b0;
  padding: 1px;
}
.failure .expected {
  text-decoration: line-through;
  color: #bb5050;
}
.ignored, .ignored * {
  background-color: #f0f0f0 !important;	
}

ins {
  text-decoration: none;	
}

.exceptionMessage {
  background-color: #fdd;
  font-family: Courier New, Courier, Monospace;
  font-size: 10pt;
  display: block;
  font-weight: normal;
  padding: 4px;
  text-decoration: none !important;
}
.stackTrace, .stackTrace * {
  font-weight: normal;
}
.stackTrace {
  display: none;
  padding: 1px 4px 4px 4px;
  background-color: #fdd;
  border-top: 1px dotted black;
}
.stackTraceExceptionMessage {
  display: block;
  font-family: Courier New, Courier, Monospace;
  font-size: 8pt;
  white-space: wrap;
  padding: 1px 0px 1px 0px;
}
.stackTraceEntry {
  white-space: nowrap;
  font-family: Courier New, Courier, Monospace;
  display: block;
  font-size: 8pt;
  padding: 1px 0px 1px 32px;
}
.stackTraceButton {
  font-size: 8pt;
  margin: 2px 8px 2px 0px;
  font-weight: normal;
  font-family: Arial;
}

.special {
  font-style: italic;
}
.missing, .missing * {
  background-color: #ff9999;
}
.surplus, .surplus * {
  background-color: #ff9999;
}
.footer {
  text-align: right;
  margin-top: 40px;
  font-size: 8pt;
  width: 100%;
  color: #999;
}
.footer .testTime {
  padding: 2px 10px 0px 0px;
}

.idea {
  font-size: 9pt;
  color: #888;
  font-style: italic;	
}
.tight li {
  margin-top: 1px;
  margin-bottom: 1px; 
}
.commentary {
  float: right;
  width: 200px;
  background-color: #ffffd0;
  padding:8px;
  border: 3px solid #eeeeb0;	 
  margin: 10px 0px 10px 10px;	 
}
.commentary, .commentary * {
  font-size: 8pt;
}
</style>
    <title>Test Data</title>
    <link href="concordion.css" rel="stylesheet" type="text/css" />
</head>

<body><span class="breadcrumbs"><a href="Framework.html">Framework</a> &gt;</span>
<h1>Test Data</h1>


<p>
    Test data is key for many tests as vast number of automated tests are data-driven. Data-driven tests are good
    candidates for test automation as they perform same actions every time but for different data sets with relatively low increase of effort comparing to manual testing.
</p>

<p>
    It's convenient to represent test data as objects of domain model to simplify tests and minimize maintenance efforts by improving tests readability.
</p>

<div class="example">
    <h4>Domain Model Example</h4>

    <p>
        Imagine that you need to test Google search.<br />
        Let's say you came up with the test where you have set of search queries and want to assert corresponding set of test results.
        So your domain model can be something like:
        <img src="Test%20Domain%20Model.png" style="display: block" />
        Where complex object of class <code>Search</code> has one object of class
        <code>Query</code> that represents search query and has multiple objects of class
        <code>Result</code> that represent search results.
        So one or multiple objects of <code>Search</code> can represent test dataset for Google Search test.
        You can see an example of similar test in <b>automated-tests</b> module.
    </p>

</div>

<p>
    Framework has convenient mechanism to work with test data in object-oriented way:
</p>
<ul>
    <li>Test data is stored as serialized object in XML files in <b>testdata</b> folder and can be retrieved with <br />
        <code>getTestData(String dataSetName)</code> method available in <code>BaseTestFixture</code> class.<br />
        <a href="http://xstream.codehaus.org/">XStream</a> is used as serialization engine.
        <div class="example">
            <p>
                <b>Given</b>
                <span c:execute="createTestDataFile(#fileName, #folderName)">
                    <span c:set="#fileName">myDataset.xml</span> file in
                    <span c:set="#folderName">testdata</span> folder
                </span><br />
                <b>When</b> <code>getTestData("<span c:set="#dataSetName">myDataset</span>")</code> is called<br />
                <b>Then</b> test data is <span c:assertTrue="testDataCanBeLoadedFrom(#dataSetName)" class="success">loaded</span><br />
            </p>
        </div>
    </li>
    <li>
        If default test data set is configured by <a href="Configuration.html">framework configuration</a> or
        <a href="RunConfiguration.html">run configuration</a> then it will be used, otherwise default.xml is used.

        <div class="example">
            <b>Given</b>
                <span c:execute="createTestDataFile(#fileName, #folderName)">
                    <span c:set="#fileName">myTestData.xml</span> file in
                    <span c:set="#folderName">testdata</span> folder
                </span><br />
            <b>And</b>
                <span c:execute="createTestDataFile(#fileName, #folderName)">
                    <span c:set="#fileName">yourTestData.xml</span> file in
                    <span c:set="#folderName">testdata</span> folder
                </span><br />
            <b>And</b>
                <span c:execute="createTestDataFile(#fileName, #folderName)">
                    <span c:set="#fileName">default.xml</span> file in
                    <span c:set="#folderName">testdata</span> folder
                </span><br />
            <table c:execute="#fileName=loadTestData(#frameworkConfig, #runConfig)">
                <tr>
                    <th c:set="#frameworkConfig">Framework Configuration</th>
                    <th c:set="#runConfig">Run Configuration</th>
                    <th c:assertEquals="#fileName">Test Data File Used</th>
                </tr>
                <tr>
                    <td />
                    <td />
                    <td class="success">default.xml</td>
                </tr>
                <tr>
                    <td>myTestData</td>
                    <td />
                    <td class="success">myTestData.xml</td>
                </tr>
                <tr>
                    <td>myTestData</td>
                    <td>yourTestData</td>
                    <td class="success">yourTestData.xml</td>
                </tr>
            </table>
        </div>
    </li>
    <li>If test dataset can not be found
        <span c:assertEquals="getExceptionForMissingTestData()" class="success">InstantiationError</span> is thrown to stop test execution.
    </li>
</ul>

<div class="footer">Results generated by <a href="http://www.concordion.org"><img src="../../../../image/concordion-logo.png" alt="Concordion" border="0" /></a><div class="testTime">in 473 ms on 21-Sep-2011 at 14:29:20 MSD</div></div></body>
</html>