-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMochaTestResultParserTests.cs
108 lines (89 loc) · 4.21 KB
/
MochaTestResultParserTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.IO;
using Agent.Plugins.Log.TestResultParser.Parser;
using Microsoft.VisualStudio.TestTools.UnitTesting;
// TODO: Add test cases containing nested test suites
namespace Agent.Plugins.UnitTests.MochaTestResultParserTests
{
[TestClass]
public class MochaTestResultParserTests : TestResultParserTestBase
{
[TestInitialize]
public void TestInit()
{
Parser = new MochaTestResultParser(TestRunManagerMock.Object, DiagnosticDataCollector.Object, TelemetryDataCollector.Object);
}
#region DataDrivenTests
[DataTestMethod]
[DynamicData(nameof(GetSuccessScenariosTestCases), DynamicDataSourceType.Method)]
public void MochaParserSuccessScenariosWithBasicAssertions(string testCase)
{
testCase = Path.Combine("MochaTestResultParserTests", "Resources", "SuccessScenarios", testCase);
TestSuccessScenariosWithBasicAssertions(testCase);
}
[DataTestMethod]
[DynamicData(nameof(GetPartialSuccessTestCases), DynamicDataSourceType.Method)]
public void MochaParserPartialSuccessScenariosWithBasicAssertions(string testCase)
{
testCase = Path.Combine("MochaTestResultParserTests", "Resources", "PartialSuccess", testCase);
TestPartialSuccessScenariosWithBasicAssertions(testCase);
}
[DataTestMethod]
[DynamicData(nameof(GetDetailedTestCases), DynamicDataSourceType.Method)]
public void MochaParserDetailedAssertions(string testCase)
{
testCase = Path.Combine("MochaTestResultParserTests", "Resources", "DetailedTests", testCase);
TestWithDetailedAssertions(testCase);
}
[DataTestMethod]
[DynamicData(nameof(GetNegativeTestCases), DynamicDataSourceType.Method)]
public void MochaParserNegativeTests(string testCase)
{
testCase = Path.Combine("MochaTestResultParserTests", "Resources", "NegativeTests", testCase);
TestNegativeTestsScenarios(testCase);
}
[DataTestMethod]
[DynamicData(nameof(GetStackTraceTestCases), DynamicDataSourceType.Method)]
public void MochaParserStackTraceTests(string testCase)
{
testCase = Path.Combine("MochaTestResultParserTests", "Resources", "StackTraceTests", testCase);
TestWithStackTraceAssertions(testCase);
}
[DataTestMethod]
[DynamicData(nameof(GetCommonNegativeTestCases), DynamicDataSourceType.Method)]
public void MochaParserCommonNegativeTests(string testCase)
{
testCase = Path.Combine("CommonTestResources", "NegativeTests", testCase);
TestNegativeTestsScenarios(testCase);
}
#endregion
#region Data Drivers
public static IEnumerable<object[]> GetSuccessScenariosTestCases()
{
return GetTestCasesFromRelativePath(Path.Combine("MochaTestResultParserTests", "Resources", "SuccessScenarios"));
}
public static IEnumerable<object[]> GetPartialSuccessTestCases()
{
return GetTestCasesFromRelativePath(Path.Combine("MochaTestResultParserTests", "Resources", "PartialSuccess"));
}
public static IEnumerable<object[]> GetDetailedTestCases()
{
return GetTestCasesFromRelativePath(Path.Combine("MochaTestResultParserTests", "Resources", "DetailedTests"));
}
public static IEnumerable<object[]> GetNegativeTestCases()
{
return GetTestCasesFromRelativePath(Path.Combine("MochaTestResultParserTests", "Resources", "NegativeTests"));
}
public static IEnumerable<object[]> GetStackTraceTestCases()
{
return GetTestCasesFromRelativePath(Path.Combine("MochaTestResultParserTests", "Resources", "StackTraceTests"));
}
public static IEnumerable<object[]> GetCommonNegativeTestCases()
{
return GetTestCasesFromRelativePath(Path.Combine("CommonTestResources", "NegativeTests"));
}
#endregion
}
}