Zum Hauptinhalt springen

B4A.UTIL.DOCU.BODY-TA-EXECUTE

Description

Details

PropertyValue
TypeDOCU
FolderPACKAGES/BEST4AUTOMIC/B4A.UTIL/CONFIG
Titlemail body for ta.Execute
Archive Key 1-
Archive Key 2-
CreatedAndreas Büsching am: 2024-09-30 16:23:27
Last ModifiedAndreas Büsching am: 2024-09-30 16:23:32 1 x
Last Used-

Text Documentation

%{XML2ATTR,PREFIX=xml,key=%(custom.key):%(custom.variable):}

%{SCRIPT:groovy:
boolean isList(object) {
def value = [Collection, ArrayList, Object[]].any { it.isAssignableFrom(object.getClass()) }
return value;
}

def getList( object ) {
if ( !isList(object) ) {
def list = []
list.add( object )
return list
}
return object
}

def printFailedSteps( title, failedSteps ) {
if ( failedSteps.size() > 0 ) {
$output.append( "<h4>$title</h4>" )
for ( step in failedSteps ) {
$output.append( """\
<p>Step: <i>$step.description</i></p>
<pre>$step.details</pre>
""")
}
}
}

def scenarios = $attributes.xml.best4Automic.ta.feature.scenario

def status = [
Success : 0,
Failure : 0
]
def steps = 0
if ( !isList(scenarios) )
scenarios = [scenarios]
for ( scenario in scenarios ) {
status[ scenario.status ] += 1
steps += getList(scenario.given.step).size() + getList(scenario.when.step).size() + getList(scenario.then.step).size()
}

if ( status.Failure == 0 ) {
$output.append( """\
<div class="notification info">Keep up the good Work!</div>
""")
} else {
$output.append( """\
<div class="notification todo">Still some work to do ...</div>
""")
}


$output.append( """\
<h1>Summary</h1>
<table>
<tr><td>Number of Tests</td><td>${scenarios.size()}</td></tr>
<tr><td>Number of Steps</td><td>$steps</td></tr>
<tr><td>Successful Tests</td><td>$status.Success</td></tr>
<tr><td>Failed Tests</td><td>$status.Failure</td></tr>
</table>
""" )

$output.append( "<h1>Test Results</h1>" )

for ( scenario in scenarios ) {
$output.append( "<h2>Scenario: $scenario.description</h2>" )

def given = scenario.given
def givenSteps = getList( given.step )
def when = scenario.when
def whenSteps = getList( when.step )
def then = scenario.then
def thenSteps = getList( then.step )

def failedGivenSteps = givenSteps.findAll{ it.status.equals( "Failure" ) }
def failedWhenSteps = whenSteps.findAll{ it.status.equals( "Failure" ) }
def failedThenSteps = thenSteps.findAll{ it.status.equals( "Failure" ) }

def statusClass = "symbol "
def symbol = "&#9744;"
if ( scenario.status.equals( "Success" ) ) {
statusClass += "success"
symbol = "&#10004;"
} else {
statusClass += "error"
symbol = "&#10006;"
}

$output.append( """\
<h3>Summary</he>
<table>
<tr><td>Result</td><td class="$statusClass">$symbol</td></tr>
""" )

if ( failedGivenSteps.size() > 0 ) {
$output.append( "<tr><td>Given Steps</td><td>${givenSteps.size()} (Failed: ${failedGivenSteps.size()})</td></tr>" )
} else {
$output.append( "<tr><td>Given Steps</td><td>${givenSteps.size()}</td></tr>" )
}
if ( failedWhenSteps.size() > 0 ) {
$output.append( "<tr><td>When Steps</td><td>${whenSteps.size()} (Failed: ${failedWhenSteps.size()})</td></tr>" )
} else {
$output.append( "<tr><td>When Steps</td><td>${whenSteps.size()}</td></tr>" )
}
if ( failedThenSteps.size() > 0 ) {
$output.append( "<tr><td>Then Steps</td><td>${thenSteps.size()} (Failed: ${failedThenSteps.size()})</td></tr>" )
} else {
$output.append( "<tr><td>Then Steps</td><td>${thenSteps.size()}</td></tr>" )
}

$output.append( """\
</table>
""" )

$output.append( "<h3>Failed Steps</h3>" )

printFailedSteps( "Given Steps", failedGivenSteps )
printFailedSteps( "When Steps", failedWhenSteps )
printFailedSteps( "Then Steps", failedThenSteps )
}
}


XML Documentation

<Content>

</Content>