private getGroups()

in test-reporter/src/parsers/java-junit/java-junit-parser.ts [78:107]


  private getGroups(suite: TestSuite): TestGroupResult[] {
    if (suite.testcase === undefined) {
      return []
    }

    const groups: {name: string; tests: TestCase[]}[] = []
    for (const tc of suite.testcase) {
      // Normally classname is same as suite name - both refer to same Java class
      // Therefore it doesn't make sense to process it as a group
      // and tests will be added to default group with empty name
      const className = tc.$.classname === suite.$.name ? '' : tc.$.classname
      let grp = groups.find(g => g.name === className)
      if (grp === undefined) {
        grp = {name: className, tests: []}
        groups.push(grp)
      }
      grp.tests.push(tc)
    }

    return groups.map(grp => {
      const tests = grp.tests.map(tc => {
        const name = tc.$.name.trim()
        const result = this.getTestCaseResult(tc)
        const time = parseFloat(tc.$.time) * 1000
        const error = this.getTestCaseError(tc)
        return new TestCaseResult(name, result, time, error)
      })
      return new TestGroupResult(grp.name, tests)
    })
  }