This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
91 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.testng.junit5; | ||
|
||
import static org.junit.platform.engine.TestExecutionResult.failed; | ||
import static org.junit.platform.engine.TestExecutionResult.successful; | ||
|
||
import java.lang.reflect.Method; | ||
import org.junit.platform.engine.EngineExecutionListener; | ||
import org.junit.platform.engine.TestDescriptor; | ||
import org.junit.platform.engine.UniqueId; | ||
import org.testng.ITestContext; | ||
import org.testng.ITestListener; | ||
import org.testng.ITestResult; | ||
|
||
class TestListener implements ITestListener { | ||
|
||
private final EngineExecutionListener platform; | ||
private final UniqueId classDescriptorId; | ||
|
||
TestListener(EngineExecutionListener platform, UniqueId classDescriptorId) { | ||
this.platform = platform; | ||
this.classDescriptorId = classDescriptorId; | ||
} | ||
|
||
private TestDescriptor convert(ITestResult result) { | ||
Method method = result.getMethod().getConstructorOrMethod().getMethod(); | ||
return MethodDescriptor.newMethodDescriptor(classDescriptorId, method); | ||
} | ||
|
||
@Override | ||
public void onTestStart(ITestResult result) { | ||
platform.executionStarted(convert(result)); | ||
} | ||
|
||
@Override | ||
public void onTestSuccess(ITestResult result) { | ||
platform.executionFinished(convert(result), successful()); | ||
} | ||
|
||
@Override | ||
public void onTestFailure(ITestResult result) { | ||
platform.executionFinished(convert(result), failed(result.getThrowable())); | ||
} | ||
|
||
@Override | ||
public void onTestSkipped(ITestResult result) { | ||
platform.executionSkipped(convert(result), "because"); | ||
} | ||
|
||
@Override | ||
public void onTestFailedButWithinSuccessPercentage(ITestResult result) { | ||
platform.executionFinished(convert(result), successful()); | ||
} | ||
|
||
@Override | ||
public void onStart(ITestContext context) {} | ||
|
||
@Override | ||
public void onFinish(ITestContext context) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters