-
Notifications
You must be signed in to change notification settings - Fork 12
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
TestNG Practitest integration implementation #4
base: master
Are you sure you want to change the base?
Changes from 3 commits
344af08
71ab180
13cd1c6
baebba4
acf1de9
10ccf9a
dafa0fc
789ce45
39f2a7a
25642e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.listeners; | ||
|
||
public class CucumberJVMListenerForPractiTest { | ||
|
||
//TODO: implement Cucumber Listener | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.listeners; | ||
|
||
public class JUnitListenerForPractiTest { | ||
|
||
//TODO: implement Junit Listener | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.listeners; | ||
|
||
import com.practitest.api.example.PractiTestWriter; | ||
import com.practitest.integration.ExtractTests; | ||
import com.webdriver.example.Utils.Log; | ||
import org.testng.ITestContext; | ||
import org.testng.ITestListener; | ||
import org.testng.ITestResult; | ||
|
||
import java.util.List; | ||
|
||
public class TestNGListenerForPractiTest implements ITestListener { | ||
|
||
protected Integer instanceID = null; | ||
|
||
|
||
@Override | ||
public void onTestStart(ITestResult result) { | ||
} | ||
|
||
@Override | ||
public void onTestSuccess(ITestResult result) { | ||
PractiTestWriter.submitResults(instanceID, 0); | ||
} | ||
|
||
@Override | ||
public void onTestFailure(ITestResult result) { | ||
PractiTestWriter.submitResults(instanceID, 1); | ||
} | ||
|
||
@Override | ||
public void onTestSkipped(ITestResult result) { | ||
} | ||
|
||
@Override | ||
public void onTestFailedButWithinSuccessPercentage(ITestResult result) { | ||
} | ||
|
||
@Override | ||
public void onStart(ITestContext context) { | ||
Integer existingTestID = PractiTestWriter.getSetID(); | ||
if (existingTestID == 0) | ||
{ | ||
List<Integer> testIDs = ExtractTests.extractAllTestIds(context); | ||
//Create test run for all tests in current execution | ||
Integer setID = PractiTestWriter.createNewSet(testIDs); | ||
//Create new instance | ||
this.instanceID = PractiTestWriter.createNewInstance(setID, testIDs); | ||
} | ||
else | ||
{ | ||
Log.info("Using existing TestSEtID: "+existingTestID.toString()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the testset exists (and going to be reused), you still have to synchronize the test in that testset. For example, a new test might be added, or some test might be removed. You should retrieve the current list of instances for the existing testset, add/remove instances as needed, and then create the runs and upload results |
||
} | ||
|
||
} | ||
|
||
|
||
@Override | ||
public void onFinish(ITestContext context) { | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why just one instanceID? There should be one instance for every test in the test set