public static void CheckResults(List <TestExecutionResults> results, TestProjectRunnerArguments args) { Assert.That(results.Count, Is.EqualTo(args.Versions.Count)); for (int versionIndex = 0; versionIndex < args.Versions.Count; versionIndex++) { string projectPath = TestProjectUtil.GetProjectPath(args, versionIndex); string testsToRunFilePath = Path.Combine(projectPath, "toRun.json"); string testsToRunFileContent = File.ReadAllText(testsToRunFilePath); ToRun runInfo = JsonConvert.DeserializeObject <ToRun>(testsToRunFileContent); List <string> testsToRun = args.DependencyCollectionGranularity == DependencyCollectionGranularity.Class ? runInfo.TestsToRun : runInfo.MethodsToRun; ISet <string> runTests = args.DependencyCollectionGranularity == DependencyCollectionGranularity.Class ? results[versionIndex].ExecutedTestClasses : results[versionIndex].ExecutedTestMethods; Assert.That(runTests.Count, Is.EqualTo(testsToRun.Count), $"Number of tests run not equal in version {versionIndex}"); for (int testIndex = 0; testIndex < testsToRun.Count; testIndex++) { Assert.That(runTests.Contains(testsToRun[testIndex]), $"Test not run: {testsToRun[testIndex]} in version: {versionIndex}"); } if (results[versionIndex].FailedTestMethodsCount > 0) { // if there is some test that failed StringBuilder failedTests = new StringBuilder(); foreach (string failedTest in results[versionIndex].FailedTestMethods) { failedTests.Append($"{failedTest}\n"); } Assert.Fail($"There were failing test cases:\n{failedTests.ToString()}"); } } }
/// <summary> /// Get absolute path to the program dll for a specified project version. /// </summary> /// <param name="versionIndex">Number of the project version</param> /// <returns></returns> public static string GetDllPath(TestProjectRunnerArguments args, int versionIndex) { var projectPath = GetProjectPath(args, versionIndex); var dllFileName = new DirectoryInfo(projectPath).Name; return(Path.Combine(projectPath, "bin\\Debug", dllFileName + ".dll")); }
/// <summary> /// Get absolute path to the specified version of project. /// </summary> /// <param name="versionIndex">Number of the project version</param> public static string GetProjectPath(TestProjectRunnerArguments args, int versionIndex) { if (versionIndex < 0 || versionIndex >= args.Versions.Count) { throw new ArgumentOutOfRangeException(); } return(Path.Combine(GetTestsDirectory(args), args.Versions[versionIndex])); }
public static string GetCSProjFilePath(TestProjectRunnerArguments args, int versionIndex) { string projectPath = GetProjectPath(args, versionIndex); return(Path.Combine(projectPath, args.Versions[versionIndex] + ".csproj")); }
/// <summary> /// Returns the absolute path to the directory that contains test projects. /// </summary> public static string GetTestsDirectory(TestProjectRunnerArguments args) { var dirInfo = new DirectoryInfo(Path.Combine(CommonPaths.TesterProjectBinDirectory, args.ProjectPath)); return(dirInfo.FullName); }