Skip to content

Commit

Permalink
HTML Report: highlight failing scenario cases (fixes #150)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Schäfer committed Oct 31, 2015
1 parent 4bca08a commit f7ed6fe
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@

* Scenarios without steps can now be excluded from the report by using the new `--exclude-empty-scenarios` report generator option [#151](https://github.com/TNG/JGiven/issues/151)
* Underlines in parameter names are now replaced with spaces [#147](https://github.com/TNG/JGiven/issues/147)
* HTML Report: highlight failing cases of a scenario [#150](https://github.com/TNG/JGiven/issues/150)

# v0.9.3

## Fixed Issues

* HTML Report: Fixed an issue that inline attachments are shown multiple times [#145](https://github.com/TNG/JGiven/issues/145)
* HTML Report: fixed an issue that inline attachments are shown multiple times [#145](https://github.com/TNG/JGiven/issues/145)
* HTML Report: fixed an issue with attachments that could lead to the generation of attachments with identical names, overriding attachments of other scenarios [#144](https://github.com/TNG/JGiven/issues/144)

## New Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ public void a_failing_scenario_for_demonstration_purposes() {
.and().steps_following_a_failed_step_should_be_skipped();
}

@Test
@DataProvider( {
"true",
"false"
} )
public void a_scenario_with_a_failing_test_case_for_demonstration_purposes( boolean withCoffees ) {
given().a_coffee_machine();

if( withCoffees ) {
given().and().there_are_$_coffees_left_in_the_machine( 2 );
}

when().I_insert_$_one_euro_coins( 2 ).
and().I_press_the_coffee_button();

then().I_should_be_served_a_coffee();
}

@Test
public void intro_words_are_not_required() {
given().a_coffee_machine()
Expand Down
4 changes: 4 additions & 0 deletions jgiven-html5-report/src/app/css/jgivenreport.css
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ span.scenario-group-header-name.failed {
color: red;
}

.scenario-case-title.failed {
color: red;
}

.scenario-title.pending {
color: gray;
}
Expand Down
6 changes: 4 additions & 2 deletions jgiven-html5-report/src/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ <h4 ng-hide="!currentPage.loading">Loading <i class="fa fa-circle-o-notch fa-spi

<div bindonce
ng-repeat="case in scenario.casesAsTable ? [scenario.scenarioCases[0]] : scenario.scenarioCases">
<h5 class="toggle" ng-click="case.expanded = !case.expanded"
<h5 class="scenario-case-title toggle {{getScenarioCaseTitleStatusClass(case)}}"
ng-click="case.expanded = !case.expanded"
ng-if="scenario.scenarioCases.length > 1 && !scenario.casesAsTable">
<i class="fa {{case.expanded ? 'fa-angle-down' : 'fa-angle-right'}} case-expand-icon"></i>Case
{{case.caseNr}}:
Expand All @@ -442,7 +443,8 @@ <h4 ng-hide="!currentPage.loading">Loading <i class="fa fa-circle-o-notch fa-spi
{{param}} = {{case.explicitArguments[$index]}}<span
ng-if="$index != scenario.explicitParameters.length - 1">, </span>
</span>
</span>
</span>
<i ng-if="!case.success" class="failed-icon fa fa-exclamation-circle"></i>
</h5>

<div ng-if="scenario.scenarioCases.length === 1 || scenario.casesAsTable || case.expanded"
Expand Down
4 changes: 4 additions & 0 deletions jgiven-html5-report/src/app/lib/reportCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ jgivenReportApp.controller('JGivenReportCtrl', function ($scope, $rootScope, $do
}
};

$scope.getScenarioCaseTitleStatusClass = function (scenarioCase) {
return scenarioCase.success ? '' : 'failed';
};

$scope.isHeaderCell = function (rowIndex, columnIndex, headerType) {
if (rowIndex === 0 && (headerType === 'HORIZONTAL' || headerType === 'BOTH')) {
return true;
Expand Down

0 comments on commit f7ed6fe

Please sign in to comment.