Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 19b34e5

Browse files
Added the Author View
1 parent c458e8a commit 19b34e5

File tree

10 files changed

+252
-26
lines changed

10 files changed

+252
-26
lines changed

dist/css/extent.css

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/extent.js

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/aventstack/extentreports/Report.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ synchronized void addScreencast(Test test, Screencast screencast) throws IOExcep
143143
});
144144
}
145145

146-
protected TestAttributeTestContextProvider<Author> getAuthorContextInfo() {
146+
protected TestAttributeTestContextProvider<Author> getAuthorContextInfo() {
147147
return authorContext;
148148
}
149149

@@ -234,6 +234,7 @@ private synchronized void notifyReporters() {
234234
x.setTestList(testCollection);
235235

236236
x.setCategoryContextInfo(categoryContext);
237+
x.setAuthorContextInfo(authorContext);
237238
x.setExceptionContextInfo(exceptionContextBuilder);
238239
x.setSystemAttributeContext(systemAttributeContext);
239240
x.setTestRunnerLogs(testRunnerLogs);

src/main/java/com/aventstack/extentreports/ReportAggregatesListener.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.List;
44

5+
import com.aventstack.extentreports.model.Author;
56
import com.aventstack.extentreports.model.Category;
67
import com.aventstack.extentreports.model.Test;
78

@@ -38,6 +39,13 @@ public interface ReportAggregatesListener {
3839
* @param categoryContext collection containing categories and all associated tests
3940
*/
4041
void setCategoryContextInfo(TestAttributeTestContextProvider<Category> categoryContext);
42+
43+
/**
44+
* Allows sharing the complete list of author and associated tests with the reporter
45+
*
46+
* @param authorContext collection containing author and all associated tests
47+
*/
48+
void setAuthorContextInfo(TestAttributeTestContextProvider<Author> authorContext);
4149

4250
/**
4351
* Allows sharing the complete list of exceptions and associated tests with the reporter

src/main/java/com/aventstack/extentreports/TestAttributeTestContextProvider.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public void setAttributeContext(T attr, Test test) {
2929

3030
boolean b = testList
3131
.stream()
32-
.filter(t -> t.getID() == test.getID())
33-
.findFirst()
34-
.isPresent();
32+
.anyMatch(t -> t.getID() == test.getID());
3533

3634
if (!b)
3735
testOptionalTestContext.get().setTest(test);
@@ -46,7 +44,7 @@ public void setAttributeContext(T attr, Test test) {
4644
}
4745
}
4846

49-
public List<TestAttributeTestContext> getCategoryTestContextList() {
47+
public List<TestAttributeTestContext> getTestAttributeTestContextList() {
5048
return testAttrCollection;
5149
}
5250

src/main/java/com/aventstack/extentreports/reporter/AbstractReporter.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.aventstack.extentreports.configuration.Config;
2424
import com.aventstack.extentreports.configuration.ConfigLoader;
2525
import com.aventstack.extentreports.configuration.ConfigMap;
26+
import com.aventstack.extentreports.model.Author;
2627
import com.aventstack.extentreports.model.Category;
2728
import com.aventstack.extentreports.model.Test;
2829

@@ -47,9 +48,10 @@ public abstract class AbstractReporter implements ExtentReporter {
4748
protected ConfigMap configContext;
4849
protected ExceptionTestContextImpl exceptionContext;
4950
protected TestAttributeTestContextProvider<Category> categoryContext;
51+
protected TestAttributeTestContextProvider<Author> authorContext;
5052
protected SystemAttributeContext systemAttributeContext;
5153
protected SessionStatusStats sc;
52-
54+
5355
public AbstractReporter() {
5456
setStartTime(Calendar.getInstance().getTime());
5557
}
@@ -129,6 +131,14 @@ public TestAttributeTestContextProvider<Category> getCategoryContextInfo() {
129131
return categoryContext;
130132
}
131133

134+
public void setAuthorContextInfo(TestAttributeTestContextProvider<Author> authorContext) {
135+
this.authorContext = authorContext;
136+
}
137+
138+
public TestAttributeTestContextProvider<Author> getAuthorContextInfo() {
139+
return authorContext;
140+
}
141+
132142
@Override
133143
public void setTestRunnerLogs(List<String> testRunnerLogs) {
134144
this.testRunnerLogs = testRunnerLogs;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<#if authorContext?? && authorContext?size != 0>
2+
<div id='author-view' class='view hide'>
3+
<section id='controls'>
4+
<div class='controls grey lighten-4'>
5+
<!-- search -->
6+
<div class='chip transparent' alt='Search Authors' title='Search Authors'>
7+
<a href="#" class='search-div'>
8+
<i class='material-icons'>search</i> Search
9+
</a>
10+
11+
<div class='input-field left hide'>
12+
<input id='search-tests' type='text' class='validate browser-default' placeholder='Search Authors...'>
13+
</div>
14+
15+
</div>
16+
<!-- search -->
17+
</div>
18+
</section>
19+
20+
<div class='subview-left left'>
21+
22+
<div class='view-summary'>
23+
<h5>Authors</h5>
24+
<ul id='author-collection' class='author-collection'>
25+
26+
<#list authorContext as author>
27+
<li class='author displayed active'>
28+
<div class='author-heading'>
29+
<span class='author-name'>${ author.name }</span>
30+
<span class='author-status right'>
31+
<#if author.passed != 0>
32+
<span class='label pass'>${ author.passed }</span>
33+
</#if>
34+
<#if author.failed != 0>
35+
<span class='label fail'>${ author.failed }</span>
36+
</#if>
37+
<#if author.others != 0>
38+
<span class='label others'>${ author.others }</span>
39+
</#if>
40+
</span>
41+
</div>
42+
<div class='author-content hide'>
43+
<div class='author-status-counts'>
44+
<#if author.passed != 0><span class='label green accent-4 white-text'>Passed: ${ author.passed }</span></#if>
45+
<#if author.failed != 0><span class='label red lighten-1 white-text'>Failed: ${ author.failed }</span></#if>
46+
<#if author.others != 0><span class='label yellow darken-2 white-text'>Others: ${ author.others }</span></#if>
47+
</div>
48+
49+
<div class='author-tests'>
50+
<table class='bordered table-results'>
51+
<thead>
52+
<tr>
53+
<th>Timestamp</th>
54+
<th>TestName</th>
55+
<th>Status</th>
56+
</tr>
57+
</thead>
58+
<tbody>
59+
<#list author.getTestList() as test>
60+
<tr>
61+
<td>${ test.startTime?datetime?string["${timeStampFormat}"] }</td>
62+
<td class='linked' test-id='${ test.getID() }'>${ test.hierarchicalName }</td>
63+
<td><span class='test-status ${ test.status }'>${ test.status }</span></td>
64+
</tr>
65+
</#list>
66+
</tbody>
67+
</table>
68+
</div>
69+
</div>
70+
</li>
71+
</#list>
72+
73+
</ul>
74+
</div>
75+
</div>
76+
77+
<div class='subview-right left'>
78+
<div class='view-summary'>
79+
<h5 class='author-name'></h5>
80+
</div>
81+
</div>
82+
</div>
83+
</#if>

src/main/resources/com/aventstack/extentreports/view/html-report/index.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<#assign extentxUrl=config.containsKey('extentx-url')?then(config.getValue('extentx-url'), '')>
77

88
<#assign systemAttributeContext=report.getSystemAttributeContext().getSystemAttributeList()>
9-
<#assign categoryContext=report.getCategoryContextInfo().getCategoryTestContextList()>
9+
<#assign categoryContext=report.getCategoryContextInfo().getTestAttributeTestContextList()>
10+
<#assign authorContext=report.getAuthorContextInfo().getTestAttributeTestContextList()>
1011
<#assign exceptionContext=report.getExceptionContextInfo().getExceptionTestContextList()>
1112

1213
<#assign parentCount=report.statusCount.parentCount>
@@ -53,6 +54,7 @@
5354

5455
<#include 'test-view/test-view.ftl'>
5556
<#include 'category-view/category-view.ftl'>
57+
<#include 'author-view/author-view.ftl'>
5658
<#include 'exception-view/exception-view.ftl'>
5759
<#include 'dashboard-view/dashboard-view.ftl'>
5860
<#include 'logs-view/testrunner-logs-view.ftl'>

src/main/resources/com/aventstack/extentreports/view/html-report/nav.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<#if categoryContext?? && categoryContext?size != 0>
99
<li class='waves-effect'><a href='#!' view='category-view' onclick="configureView(1)"><i class='material-icons'>label_outline</i></a></li>
1010
</#if>
11+
<#if authorContext?? && authorContext?size != 0>
12+
<li class='waves-effect'><a href='#!' view='author-view' onclick="configureView(3)"><i class='material-icons'>person</i></a></li>
13+
</#if>
1114
<#if exceptionContext?? && exceptionContext?size != 0>
1215
<li class='waves-effect'><a href='#!' view='exception-view' onclick="configureView(2)"><i class='material-icons'>bug_report</i></a></li>
1316
</#if>

0 commit comments

Comments
 (0)