Skip to content

Commit a1170bf

Browse files
authored
implement junit4 listener (fixes allure-framework#12, via allure-framework#26)
1 parent caf0abc commit a1170bf

80 files changed

Lines changed: 594 additions & 434 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

allure-java-commons/src/main/java/io/qameta/allure/AllureLifecycle.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,34 @@ public void startTestContainer(String parentUuid, TestResultContainer container)
6161
}
6262

6363
public void startTestContainer(TestResultContainer container) {
64-
LOGGER.info("Start test result container {}", container.getUuid());
64+
LOGGER.debug("Start test result container {}", container.getUuid());
6565
put(container.getUuid(), container)
6666
.withStart(System.currentTimeMillis());
6767
}
6868

6969
public void updateTestContainer(String uuid, Consumer<TestResultContainer> update) {
70-
LOGGER.info("Update test result container {}", uuid);
70+
LOGGER.debug("Update test result container {}", uuid);
7171
update.accept(get(uuid, TestResultContainer.class));
7272
}
7373

7474
public void stopTestContainer(String uuid) {
75-
LOGGER.info("Update test result container {}", uuid);
75+
LOGGER.debug("Update test result container {}", uuid);
7676
get(uuid, TestResultContainer.class)
7777
.withStop(System.currentTimeMillis());
7878
}
7979

8080
public void writeTestContainer(String uuid) {
81-
LOGGER.info("Stop test group {}", uuid);
81+
LOGGER.debug("Stop test group {}", uuid);
8282
writer.write(remove(uuid, TestResultContainer.class));
8383
}
8484

8585
public void startBeforeFixture(String parentUuid, String uuid, FixtureResult result) {
86-
LOGGER.info("Start test before {} with parent {}", uuid, parentUuid);
86+
LOGGER.debug("Start test before {} with parent {}", uuid, parentUuid);
8787
startFixture(parentUuid, uuid, result, TestResultContainer::getBefores);
8888
}
8989

9090
public void startAfterFixture(String parentUuid, String uuid, FixtureResult result) {
91-
LOGGER.info("Start test after {} with parent {}", uuid, parentUuid);
91+
LOGGER.debug("Start test after {} with parent {}", uuid, parentUuid);
9292
startFixture(parentUuid, uuid, result, TestResultContainer::getAfters);
9393
}
9494

@@ -104,33 +104,33 @@ private void startFixture(String parentUuid, String uuid, FixtureResult result,
104104
}
105105

106106
public void updateFixture(String uuid, Consumer<FixtureResult> update) {
107-
LOGGER.info("Update test group {}", uuid);
107+
LOGGER.debug("Update test group {}", uuid);
108108
update.accept(get(uuid, FixtureResult.class));
109109
}
110110

111111
public void stopFixture(String uuid) {
112-
LOGGER.info("Stop test before {}", uuid);
112+
LOGGER.debug("Stop test before {}", uuid);
113113
currentStepContext.remove();
114114
remove(uuid, FixtureResult.class)
115115
.withStage(Stage.FINISHED)
116116
.withStop(System.currentTimeMillis());
117117
}
118118

119119
public void scheduleTestCase(String parentUuid, TestResult result) {
120-
LOGGER.info("Add test case {} to {}", result.getUuid(), parentUuid);
120+
LOGGER.debug("Add test case {} to {}", result.getUuid(), parentUuid);
121121
get(parentUuid, TestResultContainer.class)
122122
.getChildren().add(result.getUuid());
123123
scheduleTestCase(result);
124124
}
125125

126126
public void scheduleTestCase(TestResult result) {
127-
LOGGER.info("Schedule test case {}", result.getUuid());
127+
LOGGER.debug("Schedule test case {}", result.getUuid());
128128
put(result.getUuid(), result)
129129
.withStage(Stage.SCHEDULED);
130130
}
131131

132132
public void startTestCase(String uuid) {
133-
LOGGER.info("Start test case {}", uuid);
133+
LOGGER.debug("Start test case {}", uuid);
134134
get(uuid, TestResult.class)
135135
.withStage(Stage.RUNNING)
136136
.withStart(System.currentTimeMillis());
@@ -139,20 +139,20 @@ public void startTestCase(String uuid) {
139139
}
140140

141141
public void updateTestCase(String uuid, Consumer<TestResult> update) {
142-
LOGGER.info("Update test case {}", uuid);
142+
LOGGER.debug("Update test case {}", uuid);
143143
update.accept(get(uuid, TestResult.class));
144144
}
145145

146146
public void stopTestCase(String uuid) {
147-
LOGGER.info("Stop test case {}", uuid);
147+
LOGGER.debug("Stop test case {}", uuid);
148148
currentStepContext.remove();
149149
get(uuid, TestResult.class)
150150
.withStage(Stage.FINISHED)
151151
.withStop(System.currentTimeMillis());
152152
}
153153

154154
public void writeTestCase(String uuid) {
155-
LOGGER.info("Close test case {}", uuid);
155+
LOGGER.debug("Close test case {}", uuid);
156156
writer.write(remove(uuid, TestResult.class));
157157
}
158158

@@ -162,7 +162,7 @@ public void addAttachment(String name, String type, String fileExtension, byte[]
162162

163163
public void addAttachment(String name, String type, String fileExtension, InputStream stream) {
164164
String uuid = currentStepContext.get().getFirst();
165-
LOGGER.info("Adding attachment to item with uuid {}", uuid);
165+
LOGGER.debug("Adding attachment to item with uuid {}", uuid);
166166
String extension = Optional.ofNullable(fileExtension)
167167
.filter(ext -> !ext.isEmpty())
168168
.map(ext -> ext.startsWith(".") ? ext : "." + ext)
@@ -187,7 +187,7 @@ public void startStep(String uuid, StepResult result) {
187187
}
188188

189189
public void startStep(String parentUuid, String uuid, StepResult result) {
190-
LOGGER.info("Start step {} with parent {}", uuid, parentUuid);
190+
LOGGER.debug("Start step {} with parent {}", uuid, parentUuid);
191191
put(uuid, result)
192192
.withStage(Stage.RUNNING)
193193
.withStart(System.currentTimeMillis());
@@ -203,7 +203,7 @@ public void updateStep(Consumer<StepResult> update) {
203203
}
204204

205205
public void updateStep(String uuid, Consumer<StepResult> update) {
206-
LOGGER.info("Update step {}", uuid);
206+
LOGGER.debug("Update step {}", uuid);
207207
update.accept(get(uuid, StepResult.class));
208208
}
209209

@@ -212,7 +212,7 @@ public void stopStep() {
212212
}
213213

214214
public void stopStep(String uuid) {
215-
LOGGER.info("Stop step {}", uuid);
215+
LOGGER.debug("Stop step {}", uuid);
216216
remove(uuid, StepResult.class)
217217
.withStage(Stage.FINISHED)
218218
.withStop(System.currentTimeMillis());

allure-java-commons/src/main/java/io/qameta/allure/Attachment.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,6 @@
66
import java.lang.annotation.RetentionPolicy;
77
import java.lang.annotation.Target;
88

9-
/**
10-
* A file with additional information captured during a test such
11-
* as log, screenshot, log file, dump, server response and so on.
12-
* When some test fails attachments help to understand the reason
13-
* of failure faster.
14-
* <p/>
15-
* An attachment is simply a method annotated with
16-
* {@link Attachment} returns either String or byte array
17-
* which should be added to report:
18-
* <p/>
19-
* <pre>
20-
* &#064;Attachment(value = "Page screenshot", type = "image/png")
21-
* public byte[] saveScreenshot(byte[] screenShot) {
22-
* return screenShot;
23-
* }
24-
* </pre>
25-
*
26-
* @author Dmitry Baev [email protected]
27-
* Date: 15.05.14
28-
* @since 1.4.0
29-
*/
309
@Documented
3110
@Retention(RetentionPolicy.RUNTIME)
3211
@Target(ElementType.METHOD)

allure-java-commons/src/main/java/io/qameta/allure/Flaky.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
import java.lang.annotation.RetentionPolicy;
88
import java.lang.annotation.Target;
99

10-
/**
11-
* Use this annotation to set test suite and test case title.
12-
* DisplayName overrides default name in report.
13-
*
14-
* @author Dmitry Baev [email protected]
15-
* Date: 10.24.13
16-
*/
1710
@Documented
1811
@Inherited
1912
@Retention(RetentionPolicy.RUNTIME)

allure-java-commons/src/main/java/io/qameta/allure/Links.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import java.lang.annotation.RetentionPolicy;
88
import java.lang.annotation.Target;
99

10-
/**
11-
* @author charlie (Dmitry Baev).
12-
*/
1310
@Documented
1411
@Inherited
1512
@Retention(RetentionPolicy.RUNTIME)

allure-java-commons/src/main/java/io/qameta/allure/Muted.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
import java.lang.annotation.RetentionPolicy;
88
import java.lang.annotation.Target;
99

10-
/**
11-
* @author Dmitry Baev [email protected]
12-
* Date: 10.24.13
13-
*/
1410
@Documented
1511
@Inherited
1612
@Retention(RetentionPolicy.RUNTIME)

allure-java-commons/src/main/java/io/qameta/allure/Parameter.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,6 @@
66
import java.lang.annotation.RetentionPolicy;
77
import java.lang.annotation.Target;
88

9-
/**
10-
* You can use this annotation to add parameters to your tests:
11-
* <pre>
12-
* &#064;Parameter("My Param")
13-
* private String myParameter;
14-
*
15-
* &#064;Test
16-
* public void myTest() throws Exception {
17-
* myParameter = "first";
18-
* myParameter = "second";
19-
* myParameter = "third";
20-
* }
21-
* </pre>
22-
* All three values will be added to report
23-
*
24-
* Note that the initializations of constant fields (static final fields
25-
* where the initializer is a constant string object or primitive value)
26-
* are not join points, since Java requires their references to be inlined.
27-
*
28-
* value - it's name of parameter, field name by default
29-
*
30-
* @author Dmitry Baev [email protected]
31-
* Date: 19.06.14
32-
*
33-
*
34-
*/
359
@Documented
3610
@Retention(RetentionPolicy.RUNTIME)
3711
@Target({ElementType.FIELD, ElementType.PARAMETER})

allure-java-commons/src/main/java/io/qameta/allure/Severity.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
import java.lang.annotation.RetentionPolicy;
88
import java.lang.annotation.Target;
99

10-
/**
11-
* Use the annotation to specify severity for the test. Can be
12-
* placed on test class level to specify the default severity for
13-
* all the tests.
14-
*/
1510
@Documented
1611
@Inherited
1712
@Retention(RetentionPolicy.RUNTIME)

allure-java-commons/src/main/java/io/qameta/allure/Step.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@
66
import java.lang.annotation.RetentionPolicy;
77
import java.lang.annotation.Target;
88

9-
/**
10-
* In order to define steps you need to annotate respective methods
11-
* with @Step annotation. When not specified step name equals to
12-
* annotated method name converted to human readable format. To
13-
* define explicit step name:
14-
* <pre>
15-
* &#064;Step("Open '{0}' page.")
16-
* public void openPageByAddress(String pageAddress) {
17-
* ...
18-
* }
19-
* </pre>
20-
*
21-
* @author Dmitry Baev [email protected]
22-
* Date: 10.24.13
23-
*/
249
@Documented
2510
@Retention(RetentionPolicy.RUNTIME)
2611
@Target(ElementType.METHOD)

allure-java-commons/src/test/java/io/qameta/allure/test/LinksTests.java renamed to allure-java-commons/src/test/java/io/qameta/allure/testng/LinksTests.java

File renamed without changes.

allure-junit4/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ dependencies {
99

1010
compile project(':allure-java-commons')
1111
compile 'junit:junit'
12-
compile 'org.slf4j:slf4j-simple'
12+
13+
testCompile 'org.slf4j:slf4j-simple'
14+
testCompile 'org.mockito:mockito-core'
15+
testCompile 'org.assertj:assertj-core'
1316
}
1417

1518
test.doFirst {
@@ -19,4 +22,5 @@ test.doFirst {
1922
test {
2023
useJUnit()
2124
systemProperty 'allure.results.indentOutput', true
25+
exclude '**/samples/*'
2226
}

0 commit comments

Comments
 (0)