Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Use reportTitle in the check name to support matrix builds #16

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 48 additions & 37 deletions __tests__/annotations.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { testCaseAnnotation, parseNunit, Annotation, TestResult, readResults } from '../src/nunit'
import {parseStringPromise } from 'xml2js'
import { promises as fs } from "fs";
import {
testCaseAnnotation,
parseNunit,
Annotation,
TestResult,
readResults
} from '../src/nunit'
import {parseStringPromise} from 'xml2js'
import {promises as fs} from 'fs'
import path from 'path';

test('parse TestCase', async () => {

const data = `
test('parse TestCase', async () => {
const data = `
<test-case id="1480" name="ServerUpdate" fullname="Mirror.Tests.NetworkIdentityTests.ServerUpdate" methodname="ServerUpdate" classname="Mirror.Tests.NetworkIdentityTests" runstate="Runnable" seed="1748324986" result="Failed" start-time="2020-03-22 14:13:33Z" end-time="2020-03-22 14:13:33Z" duration="0.052314" asserts="0">
<properties />
<failure>
Expand All @@ -20,46 +27,50 @@ test('parse TestCase', async () => {
]]></output>
</test-case>
`
const testCase: any = await parseStringPromise(data, {
trim: true,
mergeAttrs: true,
explicitArray: false,
})

const annotation = testCaseAnnotation(testCase['test-case']);
const testCase: any = await parseStringPromise(data, {
trim: true,
mergeAttrs: true,
explicitArray: false
})

expect(annotation).toBeTruthy();
const annotation = testCaseAnnotation(testCase['test-case'])

expect(annotation.path).toContain("Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs");
expect(annotation.start_line).toBe(895);
expect(annotation.end_line).toBe(895);
expect(annotation.title).toBe("Failed test ServerUpdate in Mirror.Tests.NetworkIdentityTests")
expect(annotation.message).toBe("Expected: 1\n But was: 0")
expect(annotation.annotation_level).toBe('failure');
expect(annotation).toBeTruthy()

expect(annotation.path).toContain(
path.join('Assets','Mirror','Tests','Editor','NetworkIdentityTests.cs')
)
expect(annotation.start_line).toBe(895)
expect(annotation.end_line).toBe(895)
expect(annotation.title).toBe(
'Failed test ServerUpdate in Mirror.Tests.NetworkIdentityTests'
)
expect(annotation.message).toBe('Expected: 1\n But was: 0')
expect(annotation.annotation_level).toBe('failure')
})


test('parse Results', async () => {
const data = await fs.readFile('__tests__/editmode-results.xml', 'utf8')

const data = await fs.readFile("__tests__/editmode-results.xml", 'utf8')

const results = await parseNunit(data);
expect(results.passed).toBe(332);
expect(results.failed).toBe(1);
const results = await parseNunit(data)
expect(results.passed).toBe(332)
expect(results.failed).toBe(1)

const annotation = results.annotations[0];
expect(annotation.path).toContain("Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs");
expect(annotation.start_line).toBe(895);
expect(annotation.end_line).toBe(895);
expect(annotation.title).toBe("Failed test ServerUpdate in Mirror.Tests.NetworkIdentityTests")
expect(annotation.message).toBe("Expected: 1\n But was: 0")
expect(annotation.annotation_level).toBe('failure');
});
const annotation = results.annotations[0]
expect(annotation.path).toContain(
path.join('Assets','Mirror','Tests','Editor','NetworkIdentityTests.cs')
)
expect(annotation.start_line).toBe(895)
expect(annotation.end_line).toBe(895)
expect(annotation.title).toBe(
'Failed test ServerUpdate in Mirror.Tests.NetworkIdentityTests'
)
expect(annotation.message).toMatch(/Expected: 1\s+But was: 0/)
expect(annotation.annotation_level).toBe('failure')
})

test('parse all Results', async () => {
var results = await readResults('__tests__/*.xml')

var results = await readResults("__tests__/*.xml");

expect(results.annotations).toHaveLength(6);
});
expect(results.annotations).toHaveLength(6)
})
Loading