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

Fix 2725 #2759

Merged
merged 2 commits into from
May 15, 2022
Merged

Fix 2725 #2759

merged 2 commits into from
May 15, 2022

Conversation

krmahadevan
Copy link
Member

Fixes #2725 .

Did you remember to?

  • Add test case(s)
  • Update CHANGES.txt
  • Auto applied styling via ./gradlew autostyleApply

We encourage pull requests that:

  • Add new features to TestNG (or)
  • Fix bugs in TestNG

If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
TestNG-dev before you spend time working on it.

Note: For more information on contribution guidelines please make sure you refer our Contributing section for detailed set of steps.

@krmahadevan krmahadevan requested a review from juherr as a code owner May 15, 2022 13:48
@krmahadevan
Copy link
Member Author

For a sample test class that looks like below

import org.testng.annotations.CustomAttribute;
import org.testng.annotations.Test;

public class TestClassSample {
  @Test(
      attributes = {
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-1"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-2"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-3"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-4"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-5"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-6"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-7"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-8"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-9"}),
        @CustomAttribute(
            name = "code_name",
            values = {"dragon_warrior-10"})
      })
  public void helloWorld() {}
}

Here's how the different reports would look like

Verbose reporter

===== Invoked methods
    TestClassSample.helloWorld()[pri:0, instance:org.testng.reporters.issue2725.TestClassSample@5b8dfcc1, attributes: <name: code_name, value:[dragon_warrior-1]>, <name: code_name, value:[dragon_warrior-2]>, <name: code_name, value:[dragon_warrior-3]>, <name: code_name, value:[dragon_warrior-4]>, <name: code_name, value:[dragon_warrior-5]>, <name: code_name, value:[dragon_warrior-6]>, <name: code_name, value:[dragon_warrior-7]>, <name: code_name, value:[dragon_warrior-8]>, <name: code_name, value:[dragon_warrior-9]>, <name: code_name, value:[dragon_warrior-10]>]
=====
PASSED: helloWorld
Test Attributes: <code_name, [dragon_warrior-1]>, <code_name, [dragon_warrior-2]>, <code_name, [dragon_warrior-3]>, <code_name, [dragon_warrior-4]>, <code_name, [dragon_warrior-5]>, <code_name, [dragon_warrior-6]>, <code_name, [dragon_warrior-7]>, <code_name, [dragon_warrior-8]>, <code_name, [dragon_warrior-9]>, <code_name, [dragon_warrior-10]>

Emailable reporter

image

testng-results.xml

<?xml version="1.0" encoding="UTF-8"?>
<testng-results ignored="0" total="1" passed="1" failed="0" skipped="0">
  <reporter-output>
  </reporter-output>
  <suite started-at="2022-05-15T19:17:51 IST" name="my_suite" finished-at="2022-05-15T19:17:51 IST" duration-ms="72">
    <groups>
    </groups>
    <test started-at="2022-05-15T19:17:51 IST" name="my_test" finished-at="2022-05-15T19:17:51 IST" duration-ms="72">
      <class name="org.testng.reporters.issue2725.TestClassSample">
        <test-method signature="helloWorld()[pri:0, instance:org.testng.reporters.issue2725.TestClassSample@5b8dfcc1, attributes: &lt;name: code_name, value:[dragon_warrior-1]&gt;, &lt;name: code_name, value:[dragon_warrior-2]&gt;, &lt;name: code_name, value:[dragon_warrior-3]&gt;, &lt;name: code_name, value:[dragon_warrior-4]&gt;, &lt;name: code_name, value:[dragon_warrior-5]&gt;, &lt;name: code_name, value:[dragon_warrior-6]&gt;, &lt;name: code_name, value:[dragon_warrior-7]&gt;, &lt;name: code_name, value:[dragon_warrior-8]&gt;, &lt;name: code_name, value:[dragon_warrior-9]&gt;, &lt;name: code_name, value:[dragon_warrior-10]&gt;]" started-at="2022-05-15T19:17:51 IST" name="helloWorld" finished-at="2022-05-15T19:17:51 IST" duration-ms="6" status="PASS">
          <reporter-output>
          </reporter-output>
          <custom-attributes>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-1]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-2]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-3]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-4]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-5]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-6]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-7]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-8]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-9]]]>
              </value>
            </custom-attribute>
            <custom-attribute>
              <name value="code_name">
              </name>
              <value>
                <![CDATA[[dragon_warrior-10]]]>
              </value>
            </custom-attribute>
          </custom-attributes>
        </test-method> <!-- helloWorld -->
      </class> <!-- org.testng.reporters.issue2725.TestClassSample -->
    </test> <!-- my_test -->
  </suite> <!-- my_suite -->
</testng-results>

individual suite level html report

image

Default html reports

image

@krmahadevan krmahadevan merged commit d190ade into testng-team:master May 15, 2022
@krmahadevan krmahadevan deleted the fix_2725 branch May 15, 2022 16:02
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.

Honour custom attribute values in TestNG default reports
2 participants