Skip to content

Commit

Permalink
Merge pull request #12 from trivago/0.6.0
Browse files Browse the repository at this point in the history
0.6.0
  • Loading branch information
Benjamin Bischoff authored Nov 30, 2017
2 parents 62325ec + 2974b53 commit 31283d5
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 26 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ Back to [Readme](README.md).
## [Unreleased]
- Ability to use custom templates
- Support for non-image attachments
- Increased unit test coverage

## [0.0.6] - 2017-11-29

### Fixed

- missing hook durations could crash during report generation
- back link fix for iframed report

### Added

- More unit tests

## [0.0.5] - 2017-11-20

Expand Down Expand Up @@ -50,7 +60,8 @@ Back to [Readme](README.md).

Initial project version on GitHub and Maven Central.

[Unreleased]: https://github.com/trivago/cluecumber-report-plugin/compare/0.0.5...HEAD
[Unreleased]: https://github.com/trivago/cluecumber-report-plugin/compare/0.0.6...HEAD
[0.0.6]: https://github.com/trivago/cluecumber-report-plugin/tree/0.0.6
[0.0.5]: https://github.com/trivago/cluecumber-report-plugin/tree/0.0.5
[0.0.4]: https://github.com/trivago/cluecumber-report-plugin/tree/0.0.4
[0.0.3]: https://github.com/trivago/cluecumber-report-plugin/tree/0.0.3
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<url>https://github.com/trivago/cluecumber-report-plugin</url>

<name>Cluecumber Maven Plugin for Cucumber Reports</name>
Expand Down Expand Up @@ -82,7 +82,7 @@
<gson.version>2.8.2</gson.version>
<gsonfire.version>1.8.1</gsonfire.version>
<chart.version>2.2.0</chart.version>
<freemarker.version>2.3.26-incubating</freemarker.version>
<freemarker.version>2.3.27-incubating</freemarker.version>
</properties>

<profiles>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/trivago/rta/json/pojo/After.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@

package com.trivago.rta.json.pojo;

import com.trivago.rta.constants.Status;

public class After extends ResultMatch {
}
22 changes: 22 additions & 0 deletions src/main/java/com/trivago/rta/json/pojo/Argument.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.trivago.rta.json.pojo;

public class Argument {
private String val;
private int offset;

public String getVal() {
return val;
}

public void setVal(final String val) {
this.val = val;
}

public int getOffset() {
return offset;
}

public void setOffset(final int offset) {
this.offset = offset;
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/trivago/rta/json/pojo/Before.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@

package com.trivago.rta.json.pojo;

import com.trivago.rta.constants.Status;

public class Before extends ResultMatch {
}
13 changes: 13 additions & 0 deletions src/main/java/com/trivago/rta/json/pojo/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

package com.trivago.rta.json.pojo;

import java.util.ArrayList;
import java.util.List;

public class Match {
private String location;
private List<Argument> arguments = new ArrayList<>();

public String getLocation() {
return location;
Expand All @@ -27,10 +31,19 @@ public void setLocation(final String location) {
this.location = location;
}

public List<Argument> getArguments() {
return arguments;
}

public void setArguments(final List<Argument> arguments) {
this.arguments = arguments;
}

@Override
public String toString() {
return "Match{" +
"location='" + location + '\'' +
", arguments=" + arguments +
'}';
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/trivago/rta/json/pojo/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package com.trivago.rta.json.pojo;

import com.google.gson.annotations.SerializedName;
import com.trivago.rta.constants.Status;
import com.trivago.rta.rendering.RenderingUtils;

public class Result {

private long duration;
private String status;
private long duration = 0;
private String status = Status.UNDEFINED.toString();

@SerializedName("error_message")
private String errorMessage;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/trivago/rta/json/pojo/ResultMatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class ResultMatch {
private Match match;

public Result getResult() {
return result;
return result != null ? result : new Result();
}

public void setResult(final Result result) {
this.result = result;
}

public Match getMatch() {
return match;
return match != null ? match : new Match();
}

public void setMatch(final Match match) {
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/com/trivago/rta/rendering/RenderingUtils.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
/*
* Copyright 2017 trivago N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.trivago.rta.rendering;

import java.time.Duration;

public class RenderingUtils {
private static final int MICROSECOND_FACTOR = 1000000;

public static String convertMicrosecondsToTimeString(long microseconds) {
public static String convertMicrosecondsToTimeString(final long microseconds) {
Duration durationMilliseconds = Duration.ofMillis(microseconds / MICROSECOND_FACTOR);
long minutes = durationMilliseconds.toMinutes();
long seconds = durationMilliseconds.minusMinutes(minutes).getSeconds();
long milliseconds = durationMilliseconds.minusMinutes(minutes).minusSeconds(seconds).toMillis();
return String.format("%dm %02ds %03dms", minutes, seconds, milliseconds);
}

public static long convertMicrosecondsToMilliseconds(long microseconds) {
public static long convertMicrosecondsToMilliseconds(final long microseconds) {
return Duration.ofMillis(microseconds / MICROSECOND_FACTOR).toMillis();
}

public static String escapeHTML(String htmlString) {
public static String escapeHTML(final String htmlString) {
StringBuilder out = new StringBuilder(Math.max(16, htmlString.length()));
for (int i = 0; i < htmlString.length(); i++) {
char c = htmlString.charAt(i);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h5 class="navbar-text float-lg-left">Test Suite Overview | ${reportDetails.date
</td>
<td class="text-left text-capitalize"
data-order="${element.totalDuration}">
<nobr>${element.totalDurationString}</nobr>
<nobr>${element.returnTotalDurationString()}</nobr>
</td>
</tr>
</#if>
Expand Down Expand Up @@ -161,7 +161,7 @@ <h5 class="navbar-text float-lg-left">Test Suite Overview | ${reportDetails.date
</td>
<td class="text-left text-capitalize"
data-order="${element.totalDuration}">
<nobr>${element.totalDurationString}</nobr>
<nobr>${element.returnTotalDurationString()}</nobr>
</td>
</tr>
</#if>
Expand Down Expand Up @@ -202,7 +202,7 @@ <h5 class="navbar-text float-lg-left">Test Suite Overview | ${reportDetails.date
</td>
<td class="text-left text-capitalize"
data-order="${element.totalDuration}">
<nobr>${element.totalDurationString}</nobr>
<nobr>${element.returnTotalDurationString()}</nobr>
</td>
</tr>
</#if>
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/template/scenario-detail/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h5 class="navbar-text float-lg-left">Scenario Details | ${reportDetails.date}</
<div class="card-header">Scenario Information</div>
<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item"><strong>Total Time:</strong> ${element.totalDurationString}</li>
<li class="list-group-item"><strong>Total Time:</strong> ${element.returnTotalDurationString()}</li>
<#list element.tags as tag>
<li class="list-group-item">${tag.name}</li>
</#list>
Expand Down Expand Up @@ -88,7 +88,7 @@ <h5 class="navbar-text float-lg-left">Scenario Details | ${reportDetails.date}</
<i>${before.glueMethodName}</i>
</div>
<div class="col-2 text-left">
<nobr>${before.result.durationString}</nobr>
<nobr>${before.result.returnDurationString()}</nobr>
</div>
<div class="col-2 text-left">
<#if before.failed>
Expand Down Expand Up @@ -123,7 +123,7 @@ <h5 class="navbar-text float-lg-left">Scenario Details | ${reportDetails.date}</
title="${step.glueMethodName}">${step.keyword} ${step.name}</span>
</div>
<div class="col-2 text-left">
<nobr>${step.result.durationString}</nobr>
<nobr>${step.result.returnDurationString()}</nobr>
</div>
<div class="col-2 text-left">
<#if step.failed>
Expand Down Expand Up @@ -170,7 +170,7 @@ <h5 class="navbar-text float-lg-left">Scenario Details | ${reportDetails.date}</
<i>${after.glueMethodName}</i>
</div>
<div class="col-2 text-left">
<nobr>${after.result.durationString}</nobr>
<nobr>${after.result.returnDurationString()}</nobr>
</div>
<div class="col-2 text-left">
<#if after.failed>
Expand Down Expand Up @@ -216,7 +216,7 @@ <h5 class="navbar-text float-lg-left">Scenario Details | ${reportDetails.date}</
<script>
function goBack() {
if (window.frameElement) {
window.parent.frames[1].history.back();
window.parent.frames[0].history.back();
} else {
window.history.back();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ public void convertJsonToReportPojosTest() throws CluecumberPluginException {
Report report = reports[0];
assertThat(report.getName(), is("Test"));
assertThat(report.getId(), is("test"));
assertThat(report.toString(), is("Report{line=1, elements=[Element{before=[ResultMatch{result=Result{duration=5554929, status='passed', errorMessage='null', durationString='null'}, match=Match{location='BeforeAfterScenario.before(Scenario)'}}], line=5, name='Test feature', description='', id='test;id', after=[ResultMatch{result=Result{duration=153270, status='passed', errorMessage='null', durationString='null'}, match=Match{location='BeforeAfterScenario.after(Scenario)'}}], type='scenario', keyword='Scenario', steps=[Step{line=7, name='the start page is opened', keyword='Given '}, Step{line=8, name='I see something', keyword='Then '}], tags=[Tag{name='@sometag'}, Tag{name='@someothertag'}], scenarioIndex=-1}], name='Test', description='', id='test', keyword='Feature', uri='parallel/features/Test.feature'}"));
assertThat(report.toString(), is("Report{line=1, elements=[Element{before=[ResultMatch{result=Result{duration=5554929, status='passed', errorMessage='null', durationString='null'}, match=Match{location='BeforeAfterScenario.before(Scenario)', arguments=[]}}], line=5, name='Test feature', description='', id='test;id', after=[ResultMatch{result=Result{duration=153270, status='passed', errorMessage='null', durationString='null'}, match=Match{location='BeforeAfterScenario.after(Scenario)', arguments=[]}}], type='scenario', keyword='Scenario', steps=[Step{line=7, name='the start page is opened', keyword='Given '}, Step{line=8, name='I see something', keyword='Then '}], tags=[Tag{name='@sometag'}, Tag{name='@someothertag'}], scenarioIndex=-1}], name='Test', description='', id='test', keyword='Feature', uri='parallel/features/Test.feature'}"));
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/trivago/rta/json/pojo/PojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;

public class PojoTest {
private static final int EXPECTED_CLASS_COUNT = 12;
private static final int EXPECTED_CLASS_COUNT = 13;
private static final String POJO_PACKAGE = "com.trivago.rta.json.pojo";

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
import org.junit.Before;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

public class PropertyManagerTest {
private PropertyManager propertyManager;
private CluecumberLogger logger;

@Before
public void setup() {
CluecumberLogger logger = mock(CluecumberLogger.class);
logger = mock(CluecumberLogger.class);
propertyManager = new PropertyManager(logger);
}

Expand All @@ -41,4 +48,20 @@ public void missingHtmlReportDirectoryTest() throws Exception {
propertyManager.setSourceJsonReportDirectory("test");
propertyManager.validateSettings();
}

@Test
public void logBasePropertiesTest() {
propertyManager.logProperties();
verify(logger, times(2)).info(anyString());
}

@Test
public void logFullPropertiesTest() {
Map<String, String> customParameters = new HashMap<>();
customParameters.put("key1", "value1");
customParameters.put("key2", "value2");
propertyManager.setCustomParameters(customParameters);
propertyManager.logProperties();
verify(logger, times(4)).info(anyString());
}
}

0 comments on commit 31283d5

Please sign in to comment.