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

Updated listener part of Testerra docs. #178

Merged
merged 4 commits into from
Dec 14, 2021
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
42 changes: 16 additions & 26 deletions docs/src/docs/extending-testerra/events-and-listener.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ Testerra provides a Google Guava event bus with custom events for test execution
|Called on start of every test method annotated by TestNG `@Test` annotation.

|`MethodEndEvent`
|Called at the end of every test method annotated by TestNG `@Test` annotation. This can be used to send test results to a test management system or issue tracker.
|Called at the end of every test method annotated by TestNG `@Test` annotation.

//|TEST_START
//|Called on start of every test method annotated by TestNG `@Test` annotation and every test configuration method annotated by TestNG `@BeforeMethod` or similar, but before the execution of registered <<Before Method Worker>>
//|TIMESTAMP+
//ITestResult +
//IInvokedMethod
|`TestStatusUpdateEvent`
|Called after the final result of every test method annotated by TestNG `@Test` annotation. A final result of a test method can be `PASSED`, `RETRIED`, `RECOVERED`, `SKIPPED`, `FAILED` or `EXPECTED_FAILED`.

This event can be used to send test results to a test management system or issue tracker.

| `ExecutionFinishEvent`
|Called at the end of test run to trigger report generation and other output worker.
Expand All @@ -26,22 +25,8 @@ Testerra provides a Google Guava event bus with custom events for test execution
|`InterceptMethodsEvent`
|Called before suite execution. The events methods list provides a list of tests to execute. Read more about this in <<Intercept test method execution>>

//|FIRST_FAILED_TEST
//|Called on the first failing test of your test run.
//|TIMESTAMP +
//METHOD_NAME +
//ITestResult +
//IInvokedMethod
//
//|TEST_WITH_FILTERED_THROWABLE
//|Called on every failed test method when Testerra `RetryAnalyzer`found a cause to retry the test.
//|TIMESTAMP +
//METHOD_NAME +
//ITestResult +
//IInvokedMethod

|`ContextUpdateEvent`
|Called every time the internal context data has been changed significantly. This can be used to synchronize the internal test context model.
|Called every time the internal context data has been changed significantly.

|`FinalizeExecutionEvent`
|Called on the very end of the test execution when the execution model has been finalized. Use this event to generate a report.
Expand All @@ -52,19 +37,24 @@ Testerra provides a Google Guava event bus with custom events for test execution

The simplest way to get in touch with the event bus is to write and register your own implementation of the event's `Listener` interface and add the `@Subscribe` annotation.

.Simple LogEventListener
.Simple event listener based on `TestStatusUpdateEvent`
[source,java]
----
import com.google.common.eventbus.Subscribe;
import eu.tsystems.mms.tic.testframework.events.MethodStartEvent;
import eu.tsystems.mms.tic.testframework.events.TestStatusUpdateEvent;
import eu.tsystems.mms.tic.testframework.report.model.context.MethodContext;
import eu.tsystems.mms.tic.testframework.logging.Loggable;

public class LogEventListener implements MethodStartEvent.Listener, Loggable {
public class MyStatusListener implements TestStatusUpdateEvent.Listener, Loggable {

@Override
@Subscribe
public void onMethodStart(MethodStartEvent event) {
log().info("Event logged: " + event.getMethod());
public void onTestStatusUpdate(TestStatusUpdateEvent event) {
MethodContext methodContext = event.getMethodContext();
log().info(
String.format("%s has the status %s", methodContext.getName(),
methodContext.getStatus())
);
}
}
----
Expand Down
7 changes: 7 additions & 0 deletions docs/src/docs/pageobject/pageobjects-overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ A page objects represents a HTML pages and or a subpage. It contains GuiElements

In your test you only uses the provided actions of your page like an API. The page object himself uses the GuiElements as an API to interact with the website.

We recommend the usage of page objects:

- They are easy to maintain.
- They improve the readability of test scripts.
- They reduce or eliminate duplicity of code.
- The pages are reusable.

== Navigation Principle
In a regular Web Application there is a defined navigation flow. This means there are pages with actions on it that let you navigate to other pages.

Expand Down