RunListener implementation questions
See original GitHub issueI am creating a custom RunListener
to update a test run on TestRail with the results from an android automation run. I have two questions:
- How important is to be able to declare the
RunListener
as thread safe?
I see if it’s not marked with @RunListener.ThreadSafe
the listener will be wrapped in the SynchronizedRunListener
. AFAIK, AndroidJUnitRunner
will run one test at the time, so I think it doesn’t matter.
- Which is the best way to know if a test passed?
The
RunListener
API doesn’t have atestPassed()
(why?) so what I did is the following:
- Create a set of
Description
s ontestRunStarted()
- If
testFailure()
ortestAssumptionFailure()
are called, add theDescription
instance to the set - When
testFinished()
is called, if theDescription
instance is not in the set, I mark the test as passed
Thanks for your time!
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
testSuccess method implementation for RunListener interface
My issue is that the interface has no testSuccess method. (for example the ITestListener from TEstNG framework has a onTestSuccess method) ...
Read more >JUnit Listeners with All Details and Examples!
In this post, we will learn how to use JUnit Listeners. We will use JUnit 4 Rules to create a listeners to listen...
Read more >JUnit Test Listener - JUnit RunListener Example
JUnit RunListener Example. 1.1. JUnit test classes. We are writing two test classes below for example only. We will monitor the logs printed...
Read more >How to implement RunListener a JUnit Listener example
In this example we will show you how you can add a JUnit Listener to your test cases. This JUnit Listener can listen...
Read more >Using RunListener in Android tests - Test Automation Chronicles
This step is the same for Android instrumented tests as well. package com.example.myapp;.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You know that a test passed when
testFinished()
is called without a prior call totestFailure()
with the sameDescription
.@Macarse regarding the issue of missing testSuccess method here is the solution i have implemented
private static final Description FAILED = Description.createTestDescription(“failed”, “failed”);
public void testFinished(Description description) throws Exception { System.out.println("Finished test: " + description.getMethodName()); if (description.getChildren().contains(FAILED)) { // action for test failed } else { // action for test success } }
// mark the test as being failed failure.getDescription().addChild(FAILED); }