|
1 |
| -# agent-java-cucumber2 |
| 1 | +# Cucumber2 Agent for ReportPortal |
| 2 | + [  ](https://github.com/reportportal/agent-java-cucumber2/_latestVersion) |
| 3 | + |
| 4 | +[](https://reportportal-slack-auto.herokuapp.com) |
| 5 | +[](http://stackoverflow.com/questions/tagged/reportportal) |
| 6 | +[](https://rpp.uservoice.com/forums/247117-report-portal) |
| 7 | +[](http://reportportal.io?style=flat) |
| 8 | + |
| 9 | + |
| 10 | +### Installation |
| 11 | + |
| 12 | +Add to POM.xml |
| 13 | + |
| 14 | +**dependency** |
| 15 | + |
| 16 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 17 | +<repositories> |
| 18 | + <repository> |
| 19 | + <snapshots> |
| 20 | + <enabled>false</enabled> |
| 21 | + </snapshots> |
| 22 | + <id>bintray-epam-reportportal</id> |
| 23 | + <name>bintray</name> |
| 24 | + <url>http://dl.bintray.com/epam/reportportal</url> |
| 25 | + </repository> |
| 26 | +</repositories> |
| 27 | +
|
| 28 | +
|
| 29 | +
|
| 30 | +<dependency> |
| 31 | + <groupId>com.epam.reportportal</groupId> |
| 32 | + <artifactId>agent-java-cucumber2</artifactId> |
| 33 | + <version>4.0.0</version> |
| 34 | +</dependency> |
| 35 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 36 | + |
| 37 | +### Install Reporter |
| 38 | + |
| 39 | +As Cucumber runs your features, it calls out to any number of listener objects to let them know |
| 40 | +how it’s progressing. These listeners are notified at various points throughout the run of features. |
| 41 | +This principle is used to notify ReportPortal about your tests progress in real-time. |
| 42 | +ReportPortal supports two kinds of Reporters. |
| 43 | +Both of them allow you to report your execution progress to ReportPortal, |
| 44 | +but there are some differences in report structure. |
| 45 | + |
| 46 | +* **Scenario Reporter** |
| 47 | +* **Step Reporter** |
| 48 | +Step Reporter propagates the most traditional for ReportPortal test structure |
| 49 | +keeping your scenarios and steps inside as separate entities. In opposite, Scenario Reporter |
| 50 | +use scenario as the base point and does not separate step from each other which is sometimes more |
| 51 | +convenient for BDD users. |
| 52 | + |
| 53 | +Enabling **StepReporter**: |
| 54 | +```java |
| 55 | +@RunWith(Cucumber.class) |
| 56 | +@CucumberOptions(plugin = {"pretty", "com.epam.reportportal.cucumber.StepReporter"}) |
| 57 | +public class RunCukesTest { |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +Enabling **ScenarioReporter**: |
| 62 | +```java |
| 63 | +@RunWith(Cucumber.class) |
| 64 | +@CucumberOptions(plugin = {"pretty", "com.epam.reportportal.cucumber.ScenarioReporter"}) |
| 65 | +public class RunCukesTest { |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | + |
| 70 | +### Configuration |
| 71 | + |
| 72 | +Copy you configuration from UI of Report Portal at [User Profile](<#user-profile>) section |
| 73 | + |
| 74 | +or |
| 75 | + |
| 76 | +In order to start using of agent, user should configure property file |
| 77 | +"reportportal.properties" in such format: |
| 78 | + |
| 79 | +**reportportal.properties** |
| 80 | + |
| 81 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 82 | +rp.endpoint = https://rp.epam.com/ |
| 83 | +rp.username = default |
| 84 | +rp.uuid = 8967de3b-fec7-47bb-9dbc-2aa4ceab8b1e |
| 85 | +rp.launch = default_TEST_EXAMPLE |
| 86 | +rp.project = default_project |
| 87 | +
|
| 88 | +## OPTIONAL PARAMETERS |
| 89 | +rp.tags = TAG1;TAG2 |
| 90 | +rp.keystore.resource = reportportal-client-v2.jks |
| 91 | +rp.keystore.password = reportportal |
| 92 | +
|
| 93 | +rp.batch.size.logs = 5 |
| 94 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 95 | + |
| 96 | + |
| 97 | +**Parameters** |
| 98 | + |
| 99 | +User should provide next parameters to agent. |
| 100 | + |
| 101 | +| **Parameter** | **Description** | **Required**| |
| 102 | +|-----------------------------------------------|----------------------|-------------| |
| 103 | +|rp.enable |Enable/Disable logging to report portal: rp.enable=true - enable log to RP server. Any other value means 'false': rp.enable=false - disable log to RP server. If parameter is skipped in properties file then automation project results will be posted on RP. |No | |
| 104 | +|rp.username |User name |Yes | |
| 105 | +|rp.password |User password. **We strongly recommend to use UUID** or separate ReportPortal internal users password here to avoid domain password publishing. |Yes | |
| 106 | +|rp.uuid |UUID of user. |Yes | |
| 107 | +|rp.endpoint |URL of web service, where requests should be sent |Yes | |
| 108 | +|rp.launch |The unique name of Launch (Run), based on that name a history of runs will be created for the particular name |Yes | |
| 109 | +|rp.project |Project name, to identify scope |Yes | |
| 110 | +|rp.tags |Set of tags for specifying additional meta information for current launch. Format: tag1;tag2;build:12345-6. Tags should be separated by “;”. There are one special tag- build – it should be used for specification number of build for launch. |No | |
| 111 | +|rp.batch.size.logs |In order to rise up performance and reduce number of requests to server |Yes | |
| 112 | +|rp.keystore.resource |Put your JKS file into resources and specify path to it | | |
| 113 | +|rp.keystore.password |Access password for JKS (certificate storage) package, mentioned above | | |
| 114 | +|rp.convertimage |Colored log images can be converted to grayscale for reducing image size. Values: ‘true’ – will be converted. Any other value means false. |No | |
| 115 | +|rp.mode |Report portal provide possibility to specify visibility of executing launch. Currently supported two modes: DEFAULT - all users from project can see this launch; DEBUG - only owner can see this launch(in debug sub tab). Note: for all java based clients(TestNg, Junit) mode will be set automaticaly to "DEFAULT" if it is not specified. |No | |
| 116 | +|rp.skipped.issue |Report Portal provide feature to mark skipped tests as not 'To Investigate' items on WS side. Parameter could be equal boolean values: *TRUE* - skipped tests considered as issues and will be mark as 'To Investigate' on portal. *FALSE* - skipped tests will not be mark as 'To Investigate' on portal. |No | |
| 117 | + |
| 118 | + |
| 119 | +Launch name can be edited once, and should be edited once, before first |
| 120 | +execution. As usual, parts of launches are fixed for a long time. Keeping the |
| 121 | +same name for launch, here we will understand a fixed list of suites under |
| 122 | +launch, will help to have a history trend, and on UI instances of the same |
| 123 | +launch will be saved with postfix "\#number", like "Test Launch \#1", "Test |
| 124 | +Launch \#2" etc. |
| 125 | + |
| 126 | +> If mandatory properties are missed client throw exception |
| 127 | +> IllegalArgumentException. |
| 128 | +
|
| 129 | +**Proxy configuration** |
| 130 | + |
| 131 | +The client uses standard java proxy mechanism. If you are new try [Java networking and proxies](<http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html>) page. |
| 132 | + |
| 133 | +Ways to set up properties: |
| 134 | + |
| 135 | +a. reportportal.properties file |
| 136 | +b. command line properties (-Dhttps.proxyHost=localhost) |
| 137 | + |
| 138 | +**How to provide parameters** |
| 139 | + |
| 140 | +There are two way to load parameters. |
| 141 | + |
| 142 | +- Load from properties file |
| 143 | + |
| 144 | +Properties file should have name: “reportportal.properties”. Properties file can |
| 145 | +be situated on the class path (in the project directory). |
| 146 | + |
| 147 | +If listener can’t find properties file it throws FileNotFoundException. By |
| 148 | +default “reportportal.properties” exists in the reportportall-client.jar, but |
| 149 | +user can create his own “reportportal.properties” file and put in class path. |
| 150 | + |
| 151 | +- Use system variables |
| 152 | + |
| 153 | +**Parameters loading order** |
| 154 | + |
| 155 | +Client loads properties in the next order. Every next level overrides previous: |
| 156 | + |
| 157 | +a. Properties file. Client loads all known to him properties (specified in the |
| 158 | + "Input Parameters" section) from "reportportal.properties" file. |
| 159 | + |
| 160 | +b. Environment variables. If environment variables with names specified in the |
| 161 | + "Input Parameters" section exist client reload existing properties from |
| 162 | + environment variables. |
| 163 | + |
| 164 | +c. JVM variables. If JVM variables with names specified in the |
| 165 | + "Input Parameters" section exist, client overrides existing ones from |
| 166 | + JVM variables. |
| 167 | + |
| 168 | +#### Events |
| 169 | + |
| 170 | +* TestRunStarted - the first event sent. |
| 171 | +* TestSourceRead - sent for each feature file read, contains the feature file source. |
| 172 | +* TestCaseStarted - sent before starting the execution of a Test Case(/Pickle/Scenario), contains the Test Case |
| 173 | +* TestStepStarted - sent before starting the execution of a Test Step, contains the Test Step |
| 174 | +* TestStepFinished - sent after the execution of a Test Step, contains the Test Step and its Result. |
| 175 | +* TestCaseFinished - sent after the execution of a Test Case(/Pickle/Scenario), contains the Test Case and its Result. |
| 176 | +* TestRunFinished - the last event sent. |
| 177 | +* EmbedEvent - calling scenario.embed in a hook triggers this event. |
| 178 | +* WriteEvent - calling scenario.write in a hook triggers this event. |
| 179 | + |
| 180 | +#### Main methods |
| 181 | + |
| 182 | +* setEventPublisher(EventPublisher publisher) - the only method that should be overidden to implement Formatter functionality |
| 183 | +* beforeLaunch - manipulations before/after the launch is started |
| 184 | +* afterLaunch - manipulations before/after the launch is finished |
| 185 | +* beforeFeature - manipulations before/after new feature is started |
| 186 | +* afterFeature - manipulations before/after current feature is finished |
| 187 | +* beforeScenario - manipulations before/after new scenario is started |
| 188 | +* afterScenario - manipulations before/after current scenario is finished |
| 189 | +* startFeature - starting new feature |
| 190 | +* startLaunch - starting new launch |
| 191 | +* beforeStep - manipulations before/after new step is started |
| 192 | +* afterStep - manipulations before/after current step is finished |
| 193 | +* beforeHooks - manipulations before/after new hook is started |
| 194 | +* afterHooks - manipulations before/after current hook is finished |
0 commit comments