Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mstest wrapper for testsuite (Closes #76) #77

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ bld/

# Cake
tools/**
!tools/packages.config
!tools/packages.config
/Developer Samples/MstestWrapperForTestsuite/MstestWrapperForTestsuite/TestResults
74 changes: 37 additions & 37 deletions Developer Samples/CommandLineTools/CommandLineTools.sln
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.421
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PromoteRuleApp", "PromoteRuleApp\PromoteRuleApp.csproj", "{62314AB8-B6B4-4480-92F8-7CAA32115C87}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildIrJsRuleApp", "BuildIrJsRuleApp\BuildIrJsRuleApp.csproj", "{23CF13F1-F24F-4C0A-8299-E95683A53435}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecuteTests", "ExecuteTests\ExecuteTests.csproj", "{9ABF0D22-46AD-49DE-B122-3180FDA2F391}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Release|Any CPU.Build.0 = Release|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Release|Any CPU.Build.0 = Release|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5723BBE-B898-46F7-A7D8-9434269D523E}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PromoteRuleApp", "PromoteRuleApp\PromoteRuleApp.csproj", "{62314AB8-B6B4-4480-92F8-7CAA32115C87}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildIrJsRuleApp", "BuildIrJsRuleApp\BuildIrJsRuleApp.csproj", "{23CF13F1-F24F-4C0A-8299-E95683A53435}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecuteTests", "ExecuteTests\ExecuteTests.csproj", "{9ABF0D22-46AD-49DE-B122-3180FDA2F391}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62314AB8-B6B4-4480-92F8-7CAA32115C87}.Release|Any CPU.Build.0 = Release|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23CF13F1-F24F-4C0A-8299-E95683A53435}.Release|Any CPU.Build.0 = Release|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9ABF0D22-46AD-49DE-B122-3180FDA2F391}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5723BBE-B898-46F7-A7D8-9434269D523E}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MstestWrapperForTestsuite", "MstestWrapperForTestsuite\MstestWrapperForTestsuite.csproj", "{C0B8E5EA-99ED-46E9-8165-2537E4FA2034}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9812F383-F8C8-4DAE-B3B9-CC678BEADC65}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0B8E5EA-99ED-46E9-8165-2537E4FA2034}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0B8E5EA-99ED-46E9-8165-2537E4FA2034}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0B8E5EA-99ED-46E9-8165-2537E4FA2034}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0B8E5EA-99ED-46E9-8165-2537E4FA2034}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {29017B77-429B-4ACD-A848-AFC2AB4B2FEA}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MstestWrapperForTestsuite
{
[TestClass]
public class DataDrivenWrapperForTestsuite : DataDrivenWrapperForTestsuiteBase
{
[DataTestMethod]
[DataSource(
"Microsoft.VisualStudio.TestTools.DataSource.CSV",
"|DataDirectory|\\data\\testsuitelist.csv",
"testsuitelist#csv",
DataAccessMethod.Sequential)]
[DeploymentItem("..\\..\\data")]
public void TestInRuleTestSuiteFromCsvDataSource()
{
var ruleAppFilePath = TestContext.DataRow["RuleAppFilePath"].ToString();
var testSuiteFilePath = TestContext.DataRow["TestSuiteFilePath"].ToString();

ExecuteInRuleTestSuite(ruleAppFilePath, testSuiteFilePath);
}

[DataTestMethod]
[FolderConventionDataSource(ruleAppPath: "ruleapp", testSuitePath: "testsuite")]
[DeploymentItem("..\\..\\data")]
public void TestInRuleFromFolderConvention(string ruleApp, string testSuite, string ruleAppFilePath, string testSuiteFilePath)
{
TestContext.WriteLine($"{ruleApp} - {testSuite}");

ExecuteInRuleTestSuite(ruleAppFilePath, testSuiteFilePath);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using InRule.Repository;
using InRule.Repository.Regression;
using InRule.Runtime;
using InRule.Runtime.Testing.Regression;
using InRule.Runtime.Testing.Regression.Runtime;
using InRule.Runtime.Testing.Session;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;

namespace MstestWrapperForTestsuite
{
[TestClass]
public abstract class DataDrivenWrapperForTestsuiteBase
{
public TestContext TestContext { get; set; }

protected TestResultCollection RunTestSuite(string ruleAppFilePath, string testSuiteFilePath)
{
if (!File.Exists(ruleAppFilePath))
{
throw new FileNotFoundException("ERROR: Rule App file not found at " + ruleAppFilePath);
}
if (!File.Exists(testSuiteFilePath))
{
throw new FileNotFoundException("ERROR: Test Suite file not found at " + testSuiteFilePath);
}

var ruleApp = new FileSystemRuleApplicationReference(ruleAppFilePath);
RuleApplicationDef ruleAppDef = ruleApp.GetRuleApplicationDef();

TestSuiteDef suite = TestSuiteDef.LoadFrom(new ZipFileTestSuitePersistenceProvider(testSuiteFilePath));
suite.ActiveRuleApplicationDef = ruleAppDef;

TestResultCollection results;
using (TestingSessionManager manager = new TestingSessionManager(new InProcessConnectionFactory()))
{
var session = new RegressionTestingSession(manager, suite);
results = session.ExecuteAllTests();
}

return results;
}

protected void ExecuteInRuleTestSuite(string ruleAppFilePath, string testSuiteFilePath)
{
if (string.IsNullOrEmpty(testSuiteFilePath) || !File.Exists(testSuiteFilePath))
{
Assert.Inconclusive($"TestSuite does not exist for {ruleAppFilePath}");
}
else
{
RunTestSuiteAndReportToContext(ruleAppFilePath, testSuiteFilePath);
}
}

private void RunTestSuiteAndReportToContext(string ruleAppFilePath, string testSuiteFilePath)
{
var testResultCollection = RunTestSuite(ruleAppFilePath, testSuiteFilePath);

TestContext.WriteLine("Using Rule App " + ruleAppFilePath);
TestContext.WriteLine("Using Test Suite " + testSuiteFilePath);

foreach (var result in testResultCollection)
{
if (result.RuntimeErrorMessage != null)
{
TestContext.WriteLine($"ERROR: Failed to execute test {result.TestDef.DisplayName}: {result.RuntimeErrorMessage}");
}
else
{
result.ReportAssertionResultsToContext(TestContext);
}

Assert.AreEqual(true, result.Passed);
Assert.IsNull(result.RuntimeErrorMessage);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C0B8E5EA-99ED-46E9-8165-2537E4FA2034}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MstestWrapperForTestsuite</RootNamespace>
<AssemblyName>MstestWrapperForTestsuite</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataDrivenWrapperForTestsuite.cs" />
<Compile Include="DataDrivenWrapperForTestsuiteBase.cs" />
<Compile Include="helpers\CustomDataSourceAttribute.cs" />
<Compile Include="helpers\InRuleReporter.cs" />
<Compile Include="helpers\SpacersLimit.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="InRule.Authoring.SDK">
<Version>5.4.0</Version>
</PackageReference>
<PackageReference Include="InRule.Common">
<Version>5.4.0</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.1.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("MstestWrapperForTestsuite")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MstestWrapperForTestsuite")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("c0b8e5ea-99ed-46e9-8165-2537e4fa2034")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RuleAppFilePath,TestSuiteFilePath
ruleapp\RectangleApp.ruleappx,testsuite\rectangleApp\Rectangle.testsuite
ruleapp\SquareApp.ruleappx,testsuite\squareApp\Square.testsuite
Loading