gotestsum icon indicating copy to clipboard operation
gotestsum copied to clipboard

Support JUnit step property

Open ledmonster opened this issue 1 year ago • 3 comments

Please support JUnit step property.

See: https://github.com/testmoapp/junitxml?tab=readme-ov-file#steps

Example

<testcase name="testExample" classname="Tests">
  <properties>
    <property name="step[passed]" value="This is a test step that passed." />
    <property name="step[failure]" value="And this step had a failure." />
    <property name="step[skipped]" value="This step wasn't executed." />
    <property name="step[error]" value="And this step had an error." />
  </properties>
</testcase>

I want an option to make 't.Run' to be steps under each test cases.

Expected Behavior

func Test(t *testing.T) {
  t.Run("A", func(t *testing.T) {}
  t.Run("B", func(t *testing.T) {}
  t.Run("C", func(t *testing.T) {
    t.Run("D", func(t *testing.T) {}
  }
}

generates

<testcase name="Test" classname="test">
  <properties>
    <property name="step[passed]" value="A" />
    <property name="step[passed]" value="B" />
    <property name="step[passed]" value="C/D" />
    <property name="step[passed]" value="C" />
  </properties>
</testcase>

ledmonster avatar Dec 12 '24 11:12 ledmonster

Contributions are welcome! If someone opens a PR for this I can review and merge it.

dnephin avatar Feb 08 '25 21:02 dnephin

@ledmonster you should be able to use #522 and a test post-processor to add this where needed

noBlubb avatar Aug 27 '25 09:08 noBlubb

Thank you!!

ledmonster avatar Aug 28 '25 00:08 ledmonster