-
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?
Conversation
public static Response sendGetSteps(String id) | ||
{ | ||
return RequestFactory.doGet("com/v2/projects/4650/steps.json?test-ids=" +id); | ||
return RequestFactory.doGet("com/v2/projects/"+projectID+"/steps.json?test-ids=" +id); |
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 the URL starts with 'com/'?
Integer setID = PractiTestWriter.createNewSet(testIDs); | ||
//Store SetID for further usage | ||
System.setProperty("currentSetId", setID.toString()); | ||
PractiTestWriter.createNewSet(testIDs); |
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.
Not sure i understand the logic here. Are you going to create a new TestSet every time 'mvn test' runs?
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.
As I understand TestSet this is collection of tests which should be executed.
For example if you specify certain test for execution you'll need new TestSet in Practitest to store results for it. Correct me if I'm wrong
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.
You right, TestSet is a collection of Tests. But subsequent executions are supposed to reuse existing TestSet.
Meaning that when you run your project first time, we should create the Tests and TestSet. When you run the project next time, we should use the TestSet created during first run.
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.
Most of the time automated and manual tests are grouped to Smoke and Regression test suites or by some other project specific definition.
This means we should have multiple TestSets for them. Including test automation process into consideration we will have only some part automated at the start and number of automated != manual test cases. From this perspective it seam to me logical to create new TestSet each time as collection of tests most of the time will be different.
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.
I can add validation to reuse test set if collection of tests already exist for this group. Please let me know if this will work for you.
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.
Yes, I think we should reuse testsets. If tests are added or removed, we should change the existing testset.
removed com from end point path.
Please check latest changes. |
*/ | ||
public static Integer getSetID() | ||
{ | ||
Response response = PractiTestAPI.sendGetTestSet(); |
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.
The PractiTestAPI.sendGetTestSet()
returns all testsets in the given project, right? You need to use name_exact
parameter to return specific testset (see https://www.practitest.com/api-v2/#get-all-testsets-in-your-project)
public static Integer createNewInstance(Integer setID, Integer testID) | ||
{ | ||
return PractiTestAPI.sendCreateInstance(setID, testID).getBody().jsonPath().get("data.id"); | ||
} | ||
|
||
public static Integer createNewInstance(Integer setID, List<Integer> testID) | ||
{ | ||
return PractiTestAPI.sendCreateInstance(setID, testID.get(0)).getBody().jsonPath().get("data.id"); |
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.
Aren't you creating instance just for first test here?
@@ -10,17 +11,21 @@ | |||
|
|||
public class TestNGListenerForPractiTest implements ITestListener { | |||
|
|||
protected Integer instanceID = null; |
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
} | ||
else | ||
{ | ||
Log.info("Using existing TestSEtID: "+existingTestID.toString()); |
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.
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
Trying to run it ( The issues so far:
Can you please tell me how to run it properly? |
it's populated with fake data and can not be executed at this stage. Integration with test project will be done as part of second assignment. |
I will wait till it's runnable then |
|
||
|
||
|
||
public static String getConfigurationValue(final String configurationName) { |
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 does it need to load the properties file every time you want to read one property?
} | ||
|
||
public static boolean setConfigurationValue(final String configurationName, final String value) { | ||
return m_props.setProperty(configurationName, value) != null; |
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.
What's the purpose of this method? It doesnt actually change anything because every time you call getConfigurationValue, you re-read the properties file from disk
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.
might be used in the future if we need to modify some config parameters during test execution
//Remove existing test IDs from List to get removed | ||
currentTestSetTestIDs.removeAll(testIDs); | ||
//Remove Instance IDs | ||
for (Integer currentTestSetTestID : currentTestSetTestIDs) { |
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.
This is not good because when instance is removed, the information about executions of these tests in this testset is removed too. Which affects statistics and reports.
You should add/remove tests that are actually added or removed.
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.
added comments with proper description how it's implemented.
@Override | ||
public void onTestFailure(ITestResult result) { | ||
List<String> instanceID = PractiTestWriter.getInstancesByTestIDAndTestSetID(result.getMethod().getDescription(), this.setID); | ||
PractiTestWriter.submitResults(instanceID.get(0), 1); |
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.
We need to send more information (how it failed, what was the exception) than just status code to PractiTest.
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.
Added throwable message to test result
Added description for add/remove tests from Test Set Failed test will contain throwable message.
No description provided.