Reporting
Reporter is a utility that turns the immaterial log representation into a visible being. Currently there are 4 reporters available:
- html, json, simple – reporters that dump logs to a file (simple uses a plain text file),
- stdout – reporter that uses the same formatting as "simple" but report is displayed in system standard output (aka console).
You can use multiple reporters or no reporters at all. To configure reporters set property bobcat.report.reporter
:
# possible values: html, json, simple, stdout
bobcat.report.reporters=html,json,simple,stdout
Simply by using test runners and turning reporting on (with a single property) you will get a basic yet comprehensive report.
Logging rule associated with the runners creates entries for test start, test end, tests result and all web driver events. If a test fails, the rule automatically creates a screenshot entry and attaches it to the log.
Currently Bobcat's reporting framework is separate from Cucumber Reports.
Property file report.properties
contains two properties that control behavior of the reporting framework:
-
bobcat.report.path
– directory where Bobcat stores report files. Default value:./target/report
. -
bobcat.report.reporters
– reporter types; allowed values are : html, json, simple, stdout. Any comma-separated combination of these values is allowed.
Following logging utilities are available:
-
ReportEntryLogger
– a basic logger that allows manual creation of log entries (common set of info, warning, error entries; allows also manual creation of sub-reports), -
@Subreport
annotation + associated interceptor.
These utilities create log entries and store them in a in-memory collection. When reported is used, these entries are present in the report. Logging sub-module contains two additional loggers that listen to web driver events and proxy events. They are always turned on.
You can create log entries manually using a ReportEntryLogger
.
To get access to the ReportEntryLogger
, inject it into your class:
import com.cognifide.qa.bb.logging.ReportEntryLogger;
// ....
@Inject
private ReportEntryLogger reportEntryLogger;
To put a custom message in the log, create an info / error entry:
reportEntryLogger.info("test info message");
reportEntryLogger.error("test error message");
There are similar methods for warning and error entries.
To put a screenshot in the report, create a screenshot entry:
reportEntryLogger.screenshot("test screenshot");
Bobcat will ask web driver to take a screenshot, store the screenshot in a file and create a log entry pointing to the file. If you don't have an active web driver instance and try to create a screenshot, logger will throw an exception.
To add an event entry to the report, use ReportEntryLogger's "event" method:
long start = System.currentTimeMillis();
checkPresenceOfSomeElement(".my.custom.locator");
long end = System.currentTimeMillis();
reportEntryLogger.event("checkingPresence", "By css (.my.custom.locator)", end - start);
Logging submodule automatically logs all WebDriver events, so you will rarely need to use Logger's "event" method.
Subreport is a named section of the log, consisting of a group of log entries. It has a beginning and end. Subreport is also a log entry, which means subreports can be nested.
Recommended way to create a subreport is by annotating any test or any public method used by a test with @Subreport
annotation.
Framework will put into the subreport all log entries created between method start point and end point. (This means that subreport will also include all entries created by methods called from the top method.)
For example:
@Subreport("someMethodSubreport")
public void someMethod() {
}
Another way to create a subreport is by invoking startSubreport
and endSubreport
:
@Test
public void test() {
reportEntryLogger.info("1");
reportEntryLogger.screenshot();
reportEntryLogger.startSubreport("a");
reportEntryLogger.info("2");
someMethod();
reportEntryLogger.screenshot();
reportEntryLogger.info("3");
reportEntryLogger.endSubreport("a");
reportEntryLogger.info("4");
reportEntryLogger.startSubreport("b");
reportEntryLogger.info("5");
reportEntryLogger.startSubreport("c");
reportEntryLogger.info("6");
}
Please notice that:
- Starting a new subreport doesn't automatically close previous subreport.
- It is a good practice to close each subreport that was opened manually.
- After test completes, all opened subreports will be closed automatically.
Below you can find out how the example HTML test report looks like:
- Configuring Bobcat
- Selenium enhancements
- Cucumber enhancements
- Traffic analyzer
- Email support
- Reporting
- Cloud integration
- Mobile integration
- Executing tests on different environments
- Working with multiple threads
- Tips and tricks
- Authoring tutorial - Classic
- AEM Classic Authoring Advanced usage
- Siteadmin
- Sidekick
- Aem Component
- Working with author pages
- Working with Publish pages
- Advanced component interactions
- Working with Context Menu
- Using Aem Content Tree
- Aem Content Finder
- Storing component configurations
- Working with packages
- Jcr Support
- Authoring tutorial - Touch UI
- Adding and editing a component
- Sites management tutorial