diff --git a/README.md b/README.md index 673760b..d20669d 100644 --- a/README.md +++ b/README.md @@ -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; @@ -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. @@ -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 @@ -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. diff --git a/src/main/java/com/github/invictum/reportportal/StepsSetProfile.java b/src/main/java/com/github/invictum/reportportal/StepsSetProfile.java index 0eb979d..f88fc2f 100644 --- a/src/main/java/com/github/invictum/reportportal/StepsSetProfile.java +++ b/src/main/java/com/github/invictum/reportportal/StepsSetProfile.java @@ -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"); + } }; /** diff --git a/src/test/java/com/github/invictum/reportportal/StepsSetProfileTest.java b/src/test/java/com/github/invictum/reportportal/StepsSetProfileTest.java index a5a8a5c..ebd0f41 100644 --- a/src/test/java/com/github/invictum/reportportal/StepsSetProfileTest.java +++ b/src/test/java/com/github/invictum/reportportal/StepsSetProfileTest.java @@ -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(), @@ -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(), @@ -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()); + } }