or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

ci-integration.mdconsole-reporters.mdindex.mdxml-reporters.md
tile.json

xml-reporters.mddocs/

0

# XML Reporters

1

2

File-based reporters that generate structured XML output for CI/CD integration and test result analysis. Supports JUnit and NUnit XML formats with extensive configuration options for file organization and content customization.

3

4

## Capabilities

5

6

### JUnit XML Reporter

7

8

Generates JUnit XML format test reports with configurable file organization and content customization. Supports both consolidated and individual file output patterns.

9

10

```javascript { .api }

11

/**

12

* Creates a JUnit XML reporter instance

13

* @param options - Configuration options for XML generation and file output

14

* @returns Reporter instance implementing Jasmine reporter interface

15

*/

16

function JUnitXmlReporter(options?: JUnitOptions): Reporter;

17

18

interface JUnitOptions {

19

/** Directory to save the files (default: '') */

20

savePath?: string;

21

/** Whether to save all test results in a single file (default: true) */

22

consolidateAll?: boolean;

23

/** Whether to save nested describes within same file as parent (default: true) */

24

consolidate?: boolean;

25

/** Whether to separate suite names with dots instead of spaces (default: true) */

26

useDotNotation?: boolean;

27

/** Whether to use fully qualified test name for TestCase name attribute (default: false) */

28

useFullTestName?: boolean;

29

/** String prepended to xml output file (default: 'junitresults-' or 'junitresults') */

30

filePrefix?: string;

31

/** Base package for all test suites (default: none) */

32

package?: string;

33

/** Delegate for modifying suite names in the junit report */

34

modifySuiteName?: (fullName: string, suite: Suite) => string;

35

/** Delegate for modifying report filenames */

36

modifyReportFileName?: (suggestedName: string, suite: Suite) => string;

37

/** Path to XSLT stylesheet to add to XML file (default: none) */

38

stylesheetPath?: string;

39

/** If true, will not include disabled attribute in XML output (default: false) */

40

suppressDisabled?: boolean;

41

/** Delegate for adding content to system-out tag as part of each testcase spec output */

42

systemOut?: (spec: Spec, qualifiedName: string) => string;

43

/** Enables capturing all stdout as spec output in xml-output elements (default: false) */

44

captureStdout?: boolean;

45

}

46

```

47

48

**Usage Examples:**

49

50

```javascript

51

// Basic usage with default options

52

const junitReporter = new jasmineReporters.JUnitXmlReporter();

53

jasmine.getEnv().addReporter(junitReporter);

54

55

// Consolidated output to specific directory

56

const junitReporter = new jasmineReporters.JUnitXmlReporter({

57

savePath: './test-results',

58

consolidateAll: true,

59

filePrefix: 'junit-results'

60

});

61

62

// Separate files per suite with custom naming

63

const junitReporter = new jasmineReporters.JUnitXmlReporter({

64

savePath: './test-results',

65

consolidateAll: false,

66

consolidate: false,

67

useDotNotation: true,

68

modifySuiteName: function(generatedSuiteName, suite) {

69

return 'MyApp.' + generatedSuiteName;

70

}

71

});

72

73

// Protractor multi-capability setup

74

const junitReporter = new jasmineReporters.JUnitXmlReporter({

75

consolidateAll: true,

76

savePath: 'testresults',

77

filePrefix: browserName + '-xmloutput',

78

modifySuiteName: function(generatedSuiteName, suite) {

79

return browserName + '.' + generatedSuiteName;

80

}

81

});

82

```

83

84

### NUnit XML Reporter

85

86

Generates NUnit XML format test reports with simpler configuration focused on single-file output and custom report naming.

87

88

```javascript { .api }

89

/**

90

* Creates an NUnit XML reporter instance

91

* @param options - Configuration options for NUnit XML generation

92

* @returns Reporter instance implementing Jasmine reporter interface

93

*/

94

function NUnitXmlReporter(options?: NUnitOptions): Reporter;

95

96

interface NUnitOptions {

97

/** Directory to save the files (default: '') */

98

savePath?: string;

99

/** Name of xml output file (default: 'nunitresults.xml') */

100

filename?: string;

101

/** Name for parent test-results node (default: 'Jasmine Results') */

102

reportName?: string;

103

}

104

```

105

106

**Usage Examples:**

107

108

```javascript

109

// Basic usage with default options

110

const nunitReporter = new jasmineReporters.NUnitXmlReporter();

111

jasmine.getEnv().addReporter(nunitReporter);

112

113

// Custom filename and location

114

const nunitReporter = new jasmineReporters.NUnitXmlReporter({

115

savePath: './build/test-results',

116

filename: 'nunit-test-results.xml',

117

reportName: 'MyApplication Test Results'

118

});

119

```

120

121

### File Writing Methods

122

123

Both XML reporters provide file writing capabilities across different environments.

124

125

```javascript { .api }

126

/**

127

* Writes XML content to file using environment-appropriate method

128

* @param filename - Name of file to write (extension added automatically if missing)

129

* @param text - XML content to write to file

130

*/

131

writeFile(filename: string, text: string): void;

132

```

133

134

**Environment Support:**

135

136

- **Node.js**: Uses `fs` module with `mkdirp` for directory creation

137

- **PhantomJS**: Uses injected `__phantom_writeFile` method

138

- **Error Handling**: Logs warnings if file writing fails in both environments

139

140

### Reporter Lifecycle Methods

141

142

All XML reporters implement the complete Jasmine reporter interface.

143

144

```javascript { .api }

145

/** Called when Jasmine starts running */

146

jasmineStarted(summary?: Summary): void;

147

148

/** Called when a test suite starts */

149

suiteStarted(suite: Suite): void;

150

151

/** Called when a test spec starts */

152

specStarted(spec: Spec): void;

153

154

/** Called when a test spec completes */

155

specDone(spec: Spec): void;

156

157

/** Called when a test suite completes */

158

suiteDone(suite: Suite): void;

159

160

/** Called when all tests have completed */

161

jasmineDone(): void;

162

```

163

164

## XML Output Formats

165

166

### JUnit XML Structure

167

168

```xml

169

<?xml version="1.0" encoding="UTF-8" ?>

170

<testsuites disabled="0" errors="0" failures="1" tests="3" time="0.123">

171

<testsuite name="Suite Name" timestamp="2023-01-01T12:00:00" hostname="localhost"

172

time="0.123" errors="0" tests="2" skipped="0" disabled="0" failures="1">

173

<testcase classname="Suite Name" name="should pass" time="0.001" />

174

<testcase classname="Suite Name" name="should fail" time="0.122">

175

<failure type="exception" message="Expected true to be false">

176

<![CDATA[Error: Expected true to be false

177

at Object.<anonymous> (spec.js:10:5)]]>

178

</failure>

179

</testcase>

180

</testsuite>

181

</testsuites>

182

```

183

184

### NUnit XML Structure

185

186

```xml

187

<?xml version="1.0" encoding="utf-8" ?>

188

<test-results name="Jasmine Results" total="2" failures="1" not-run="0"

189

date="2023-01-01" time="12:00:00">

190

<test-suite name="Suite Name" executed="true" success="false" time="0.123">

191

<results>

192

<test-case name="should pass" executed="true" success="true" time="0.001" />

193

<test-case name="should fail" executed="true" success="false" time="0.122">

194

<failure>

195

<message><![CDATA[Expected true to be false]]></message>

196

<stack-trace><![CDATA[Error: Expected true to be false

197

at Object.<anonymous> (spec.js:10:5)]]></stack-trace>

198

</failure>

199

</test-case>

200

</results>

201

</test-suite>

202

</test-results>

203

```