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

TestNG Practitest integration implementation #4

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

vdemkiv
Copy link
Contributor

@vdemkiv vdemkiv commented Jan 22, 2018

No description provided.

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);
Copy link
Member

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);
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

vdemkiv and others added 2 commits February 7, 2018 18:56
@vdemkiv
Copy link
Contributor Author

vdemkiv commented Feb 25, 2018

Please check latest changes.

*/
public static Integer getSetID()
{
Response response = PractiTestAPI.sendGetTestSet();
Copy link
Member

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");
Copy link
Member

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;
Copy link
Member

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());
Copy link
Member

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

@stask
Copy link
Member

stask commented Mar 21, 2018

Trying to run it (mvn test) and got few issues. Did you commit everything?

The issues so far:

  • seems like some properties are taken from src/main/resources/project.properties while other should be specified via -D (-DPROJECT_ID=2 for instance)
  • NullPointerExceptions

Can you please tell me how to run it properly?

@vdemkiv
Copy link
Contributor Author

vdemkiv commented Mar 21, 2018

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.

@stask
Copy link
Member

stask commented Mar 21, 2018

I will wait till it's runnable then




public static String getConfigurationValue(final String configurationName) {
Copy link
Member

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;
Copy link
Member

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

Copy link
Contributor Author

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) {
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Contributor Author

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

vdemkiv added 2 commits May 23, 2018 00:33
Added description for add/remove tests from Test Set
Failed test will contain throwable message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants