Skip to content

Commit

Permalink
closes #393 Add (manual) scroll to each failed step
Browse files Browse the repository at this point in the history
  • Loading branch information
anshooarora committed Aug 12, 2023
1 parent a72cd73 commit 36c7418
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 27 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/aventstack/extentreports/ExtentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ public ExtentTest createNode(Class<? extends IGherkinFormatterModel> type, Strin
* @return {@link ExtentTest}
*/
public ExtentTest createNode(GherkinKeyword gherkinKeyword, String name, String description) {
if (gherkinKeyword == null) {
return createNode(name, description);
}
return createNode(gherkinKeyword.getKeyword().getClass(), name, description);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class JsonDeserializer {
private File f;

public JsonDeserializer(File f) {
public JsonDeserializer(final File f) {
this.f = f;
}

Expand All @@ -25,8 +25,7 @@ public List<Test> deserialize() throws IOException {
.withScreenCaptureTypeAdapter()
.build();
String json = new String(Files.readAllBytes(f.toPath()));
Type t = new TypeToken<ArrayList<Test>>() {
}.getType();
Type t = new TypeToken<ArrayList<Test>>(){}.getType();
List<Test> tests = gson.fromJson(json, t);
return tests;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
public class RawEntityConverter {
private final ExtentReports extent;

public RawEntityConverter(ExtentReports extent) {
public RawEntityConverter(final ExtentReports extent) {
this.extent = extent;
}

public void convertAndApply(File jsonFile) throws IOException {
if (!jsonFile.exists())
public void convertAndApply(final File jsonFile) throws IOException {
if (!jsonFile.exists()) {
return;
}

extent.setReportUsesManualConfiguration(true);
List<Test> tests = new JsonDeserializer(jsonFile).deserialize();
for (Test test : tests) {
Expand Down Expand Up @@ -64,12 +66,13 @@ else if (log.hasMedia())

// handle nodes
for (Test node : test.getChildren()) {
ExtentTest extentNode = null;
if (node.getBddType() == null)
ExtentTest extentNode;
if (!node.isBDD()) {
extentNode = extentTest.createNode(node.getName(), node.getDescription());
else
extentNode = extentTest.createNode(new GherkinKeyword(node.getBddType().getSimpleName()), node.getName(),
node.getDescription());
} else {
GherkinKeyword gk = new GherkinKeyword(node.getBddType().getSimpleName());
extentNode = extentTest.createNode(gk, node.getName(), node.getDescription());
}
addMedia(node, extentNode);
createDomain(node, extentNode);
}
Expand All @@ -82,8 +85,7 @@ private void addMedia(Log log, ExtentTest extentTest, Throwable ex) {
MediaEntityBuilder.createScreenCaptureFromPath(m.getPath()).build());
} else if (((ScreenCapture) m).getBase64() != null) {
extentTest.log(log.getStatus(), ex,
MediaEntityBuilder.createScreenCaptureFromBase64String(((ScreenCapture) m).getBase64())
.build());
MediaEntityBuilder.createScreenCaptureFromBase64String(((ScreenCapture) m).getBase64()).build());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
public class ScreenCaptureTypeAdapter extends TypeAdapter<Media> {

@Override
public void write(JsonWriter out, Media value) throws IOException {
}
public void write(JsonWriter out, Media value) throws IOException { }

@Override
public Media read(JsonReader reader) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
return null;
}

final Map<String, T> lowercaseToConstant = new HashMap<String, T>();
final Map<String, T> lowercaseToConstant = new HashMap<>();
for (T constant : rawType.getEnumConstants()) {
lowercaseToConstant.put(toLowercase(constant), constant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ public JsonConfigLoader(T instance, String json) {

private void init(T instance) {
this.instance = instance;
creator = new InstanceCreator<T>() {
@Override
public T createInstance(Type type) {
return instance;
}
};
creator = type -> instance;
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class XmlConfigLoader<T> implements ConfigLoadable<T> {
private InputStream stream;
private T instance;

public XmlConfigLoader(T instance, File f) throws FileNotFoundException {
public XmlConfigLoader(T instance, File f) {
createStream(f);
this.instance = instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<#assign
resourceCDN=config.resourceCDN
cdnURI="cdn.jsdelivr.net/gh/extent-framework/extent-github-cdn@"
csscommit="d6562a79075e061305ccfdb82f01e5e195e2d307"
jscommit="d6562a79075e061305ccfdb82f01e5e195e2d307"
csscommit="ce8b10435bcbae260c334c0d0c6b61d2c19b6168"
jscommit="ce8b10435bcbae260c334c0d0c6b61d2c19b6168"
iconcommit="b00a2d0486596e73dd7326beacf352c639623a0e">
<#if resourceCDN=="extentreports">
<#assign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@
<span class='badge badge-danger'>${test.endTime?string("MM.dd.yyyy")} ${test.endTime?time?string}</span>
<span class='badge badge-default'>${test.timeTakenPretty()}</span>
&middot; <span class='uri-anchor badge badge-default'>#test-id=${test.getId()}</span>
<span class='badge badge-default pointer float-right ml-1 et'><i class="fa fa-chevron-down"></i></span>
<span class='badge badge-default pointer float-right ct'><i class="fa fa-chevron-up"></i></span>
<span title='Skip to the next failed step' class='badge badge-danger pointer float-right ne ml-1'><i class="fa fa-fast-forward"></i></span>
<span title='Collapse all nodes' class='badge badge-default pointer float-right ct ml-1'><i class="fa fa-compress"></i></span>
<span title='Expand all nodes' class='badge badge-default pointer float-right et'><i class="fa fa-expand"></i></span>
</div>
<#if test.hasAttributes()>
<div class="m-t-15"><@attributes test=test /></div>
Expand Down

0 comments on commit 36c7418

Please sign in to comment.