Skip to content

Commit

Permalink
Merge pull request #27 from Invictum/23_Tree_mode_optimized_profile
Browse files Browse the repository at this point in the history
23 tree mode optimized profile
  • Loading branch information
Invictum authored Jun 22, 2018
2 parents 424d963 + ea09a99 commit 503b369
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 21 deletions.
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());
}
}

0 comments on commit 503b369

Please sign in to comment.