Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

23 tree mode optimized profile #27

Merged
merged 2 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ Each Serenity `TestStep` object is passed through chain of configured `StepProce

- DEFAULT
- FULL
- TREE_OPTIMIZED
- CUSTOM

`DEFAULT` profile is used by default and contains all usually required reporting details. It generates in Report Portal a nice log that does not cluttered with extra details.

`FULL` profile contains all available `StepProcessors` and generates full reporting.

`TREE_OPTIMIZED` profile is sutable to use with `TREE` handler type. Reffer to Handler Type section for more details.

To customize what should be logged `CUSTOM` profile should be used.
```
StepsSetProfile config = StepsSetProfile.CUSTOM;
Expand Down Expand Up @@ -125,6 +128,22 @@ public class MyCustomLoggerLogger implements StepProcessor {

The order of processors registration is matters, this order the same as order of invocation.

**Handler type (expiremental feature)**

Integration provides two strategies of storing Serenity's test data to Report Portal facility:
- *FLAT* (default behaviour) - Represents steps data as plain logs emmited to the test scope
- *TREE* - Reconstructs steps structure as a tree representation in RP

Report Portal has a few limitations regurding to flexible nested structures support for now. As a result test report may contain some inaccuracate data.
E. g. test count for launch will show total number of tests + total number of steps.

Nevertheless `TREE` configuration allows to get additional features with RP. E. g. integrated RP test analisys facility scope will be changed from test to step.

Handler type may be changed with following configuration
```
ReportIntegrationConfig.handlerType = HandlerType.TREE;
```

**Narrative formatter**

By default, narrative is formatted as a bullet list before storring to the test description field. It is possible to alter this logic in accordance to project needs.
Expand All @@ -141,7 +160,7 @@ public class NumberedListFormatter implements NarrativeFormatter {
}
```

Code snippet abowe will format narrative lines as a numbered list.
Code snippet above will format narrative lines as a numbered list.
```
Initial lines
line 1, line 2
Expand All @@ -156,22 +175,6 @@ Custom `NarrativeFormatter` should be registered via configuration
ReportIntegrationConfig.narrativeFormatter = new NumberedListFormatter();
```

**Handler type (expiremental feature)**

Integration provides two strategies of storing Serenity's test data to Report Portal facility:
- FLAT (default behaviour) - Represents steps data as plain logs emmited to the test scope
- TREE - Reconstructs steps structure as a tree representation in RP

Report Portal has a few limitations regurding to flexible nested structures support for now. As a result test report may contain some inaccuracate data.
E. g. test count for launch will show total number of tests + total number of steps.

Nevertheless `TREE` configuration allows to get additional features with RP. E. g. integrated RP test analisys facility scope will be changed from test to step.

Handler type may be changed with following configuration
```
ReportIntegrationConfig.handlerType = HandlerType.TREE;
```

> **Notice**
All integration configurations should be provided before Serenity facility init (For example on `@BeforeClass` method on the parent test class for jUnit style tests). Otherwise default values will be used.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ public StepsSetProfile registerProcessors(StepProcessor... steps) {
this.steps = steps;
return this;
}
},

/**
* Processors set designed to use in TREE handler mode.
*/
TREE_OPTIMIZED() {
@Override
StepProcessor[] processors() {
return new StepProcessor[]{
new ScreenshotAttacher(),
new ErrorLogger(true)
};
}

@Override
public StepsSetProfile registerProcessors(StepProcessor... steps) {
throw new UnsupportedOperationException("Unable to register processors for TREE_OPTIMIZED profile");
}
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class StepsSetProfileTest {

@Test
public void fullProfileTest() {
public void fullProfile() {
StepProcessor[] actual = StepsSetProfile.FULL.processors();
StepProcessor[] expected = new StepProcessor[]{
new StartStepLogger(),
Expand All @@ -23,8 +23,13 @@ public void fullProfileTest() {
Assert.assertArrayEquals(actual, expected);
}

@Test(expected = UnsupportedOperationException.class)
public void fullProfileCustomization() {
StepsSetProfile.FULL.registerProcessors(new ScreenshotAttacher());
}

@Test
public void defaultProfileTest() {
public void defaultProfile() {
StepProcessor[] actual = StepsSetProfile.DEFAULT.processors();
StepProcessor[] expected = new StepProcessor[]{
new FinishStepLogger(),
Expand All @@ -35,14 +40,29 @@ public void defaultProfileTest() {
}

@Test(expected = UnsupportedOperationException.class)
public void defaultProfileCustomizationTest() {
public void defaultProfileCustomization() {
StepsSetProfile.DEFAULT.registerProcessors(new ScreenshotAttacher());
}

@Test
public void customProfileTest() {
public void customProfileCustomization() {
StepsSetProfile profile = StepsSetProfile.CUSTOM.registerProcessors(new ScreenshotAttacher());
StepProcessor[] expected = new StepProcessor[]{new ScreenshotAttacher()};
Assert.assertArrayEquals(profile.processors(), expected);
}

@Test
public void treeOptimizedProfile() {
StepProcessor[] actual = StepsSetProfile.TREE_OPTIMIZED.processors();
StepProcessor[] expected = new StepProcessor[]{
new ScreenshotAttacher(),
new ErrorLogger(true)
};
Assert.assertArrayEquals(actual, expected);
}

@Test(expected = UnsupportedOperationException.class)
public void treeOptimizedProfileCustomization() {
StepsSetProfile.TREE_OPTIMIZED.registerProcessors(new HtmlSourceAttacher());
}
}