Test using TestNG

Introduction

TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing (testing a class in isolation of the others) to integration testing (testing entire systems made of several classes, several packages, and even several external frameworks, such as application servers).

Writing a test is typically a three-step process:

  • Write the business logic of your test and insert TestNG annotations in your code.

  • Add the information about your test (e.g. the class name, the groups you wish to run, etc.) in a testng.xml file or build.xml.

  • Run TestNG.

Here is how you can specify the Test Cycle, Test Cases, and Test Steps that will be created in QMetry as a part of the result files.

Automation Hierarchy

Test Cycle

Test Case

Test Step Tag

1 (default)

NA

Test Name is created as Test Case.

  • <test> tag under the <suite> tag will be considered as test case.

  • 'name' attribute of <test> tag will be used as test case summary.

Test Method Name is created as Test Step.

  • <test-method> tag under <class> tag (with attribute "is-config" not set as true) will be considered as test case step.

  • 'name' attribute of <test-method> tag will be used as test case step description.

2

Test Name is created as Test Cycle.

If there are multiple tests in the result file then multiple test cycles will be created based on the test name.

  • <test> tag under the <suite> tag will be considered as test cycle.

  • 'name' attribute of <test> tag will be used as test cycle summary.

→ The parameter Test Cycle to Reuse will be ignored in the Automation.

Test Method Name is created as Test Case.

  • <test-method> tag under <class> tag (with attribute "is-config" not set as true) will be considered as test case case.

  • 'name' attribute of <test-method> tag will be used as test case summary.

NA

3

Suite Name is created as Test Cycle.

If there are multiple suites in the result file then multiple test cycles will be created based on the suite name.

  • The <suite> tag will be considered as test cycle.

  • 'name' attribute of <suite> tag will be used as test cycle summary.

→ If the value is provided for the Test Cycle to Reuse parameter, then the suite name in the files will be ignored. All the test case results for all suites and files will be uplaoded in a single cycle similar to Hierarchy 1 (default).

Test Method Name is created as Test Cases.

  • <test-method> tag under <class> tag (with attribute "is-config" not set as true) will be considered as test case case.

  • 'name' attribute of <test-method> tag will be used as test case summary.

NA

Note: If the Test Name or Test Suite Name length is more than 255 characters, the name will be truncated.

Supported Version: 1.2.5

Supported file types: XML

Sample Test Result File

Click

The specified stories will be linked to the created/reused test case.

  • When a valid story entity key is passed through the result xml file, the test case which is created using <class> is linked to the story.

  • When an invalid/archived story entity key is passed through result xml file, no story will be linked to the test case which is created using <class>.

  • Cross-project stories can also be linked to the test case.

  • Multiple storykey can be used in the same tag in the file to link multiple stories to the test cases. e.g.

<group name="storykey:FIT-1 FIT-2 OPT-3">

  • If multiple test case keys are mentioned, then the multiple stories will be linked with the test cases individually.

  • The users should have Test Case Edit and Requirement Edit permissions.

  • When Group(s) are defined at Suite level followed by a Test(s): If the Group's Class Name matches with the Test's Class Name, the Test Case Key/Story will be linked with those Tests.

Publication date: