Skip to content
Merged
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
27 changes: 27 additions & 0 deletions TestFx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatTestProject", "test\E
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProjectForAssemblyResolution", "test\ComponentTests\TestAssets\TestProjectForAssemblyResolution\TestProjectForAssemblyResolution.csproj", "{0B057B99-DCDD-417A-BC19-3E63DDD86F24}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataRowTestProject", "test\E2ETests\TestAssets\DataRowTestProject\DataRowTestProject.csproj", "{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{272ca5e1-8e81-4825-9e47-86cce02f700d}*SharedItemsImports = 13
Expand Down Expand Up @@ -1039,6 +1041,30 @@ Global
{0B057B99-DCDD-417A-BC19-3E63DDD86F24}.Release|x64.Build.0 = Release|Any CPU
{0B057B99-DCDD-417A-BC19-3E63DDD86F24}.Release|x86.ActiveCfg = Release|Any CPU
{0B057B99-DCDD-417A-BC19-3E63DDD86F24}.Release|x86.Build.0 = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|Any CPU.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|ARM.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|ARM.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|x64.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|x64.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|x86.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Code Analysis Debug|x86.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|ARM.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|x64.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|x64.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|x86.ActiveCfg = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Debug|x86.Build.0 = Debug|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|Any CPU.Build.0 = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|ARM.ActiveCfg = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|ARM.Build.0 = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|x64.ActiveCfg = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|x64.Build.0 = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|x86.ActiveCfg = Release|Any CPU
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1098,6 +1124,7 @@ Global
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{0B057B99-DCDD-417A-BC19-3E63DDD86F24} = {1899187D-8B9C-40C2-9F04-9E9A76C9A919}
{7FB80AAB-7123-4416-B6CD-8D3D69AA83F1} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ internal UnitTestResult[] RunTestMethod()
}
else
{
UTF.ITestDataSource[] testDataSources = this.testMethodInfo.GetAttributes<Attribute>(true)?.Where(a => a is UTF.ITestDataSource).OfType<UTF.ITestDataSource>().ToArray();
UTF.ITestDataSource[] testDataSources = this.testMethodInfo.GetAttributes<Attribute>(false)?.Where(a => a is UTF.ITestDataSource).OfType<UTF.ITestDataSource>().ToArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.


if (testDataSources != null && testDataSources.Length > 0)
{
Expand Down
10 changes: 7 additions & 3 deletions test/E2ETests/Automation.CLI/CLITestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,16 @@ public void ValidateDiscoveredTests(params string[] discoveredTestsList)
/// <remarks>Provide the full test name similar to this format SampleTest.TestCode.TestMethodPass.</remarks>
public void ValidatePassedTests(params string[] passedTests)
{
// Make sure only expected number of tests passed and not more.
Assert.AreEqual(passedTests.Length, this.runEventsHandler.PassedTests.Count);

this.ValidatePassedTestsCount(passedTests.Length);
this.ValidatePassedTestsContain(passedTests);
}

public void ValidatePassedTestsCount(int expectedPassedTestsCount)
{
// Make sure only expected number of tests passed and not more.
Assert.AreEqual(expectedPassedTestsCount, this.runEventsHandler.PassedTests.Count);
}

/// <summary>
/// Validates if the test results have the specified set of failed tests.
/// </summary>
Expand Down
45 changes: 45 additions & 0 deletions test/E2ETests/Smoke.E2E.Tests/DataRowTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace MSTestAdapter.Smoke.E2ETests
{
using Microsoft.MSTestV2.CLIAutomation;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class DataRowTests : CLITestBase
{
private const string TestAssembly = "DataRowTestProject.dll";

[TestMethod]
public void ExecuteOnlyDerivedClassDataRowsWhenBothBaseAndDerviedClassHasDataRows()
{
this.InvokeVsTestForExecution(new string[] { TestAssembly });

this.ValidatePassedTestsContain(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this validation change after using the filter ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By mistake added filter in first test.

"DataRowTestMethod (BaseString1)",
"DataRowTestMethod (BaseString2)",
"DataRowTestMethod (BaseString3)",
"DataRowTestMethod (DerivedString1)",
"DataRowTestMethod (DerivedString2)");

// 4 tests of BaseClass - 3 datarow result and 1 parent result
// 3 tests of DerivedClass - 2 datarow result and 1 parent result
// Total 7 tests - Making sure that DerivedClass doesn't run BaseClass tests
this.ValidatePassedTestsCount(7);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is little confusing.
We should rather run only the DerviedClass tests using filter maybe and then check for only that.
We can keep this one as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realize the confusion. Added new test.

}

[TestMethod]
public void ExecuteOnlyDerivedClassDataRowsWhenItOverridesBaseClassDataRows()
{
this.InvokeVsTestForExecution(new string[] { TestAssembly }, testCaseFilter: "FullyQualifiedName~DerivedClass");

this.ValidatePassedTestsContain(
"DataRowTestMethod (DerivedString1)",
"DataRowTestMethod (DerivedString2)");

// 3 tests of DerivedClass - 2 datarow result and 1 parent result
this.ValidatePassedTestsCount(3);
}
}
}
1 change: 1 addition & 0 deletions test/E2ETests/Smoke.E2E.Tests/Smoke.E2E.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DynamicDataExtensibilityTests.cs" />
<Compile Include="TestDataSourceExtensibilityTests.cs" />
<Compile Include="DataRowTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
20 changes: 20 additions & 0 deletions test/E2ETests/TestAssets/DataRowTestProject/BaseClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace DataRowTestProject
{
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class BaseClass
{
[TestMethod]
[DataRow("BaseString1")]
[DataRow("BaseString2")]
[DataRow("BaseString3")]
public virtual void DataRowTestMethod(string a)
{
Assert.IsTrue(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TestFxRoot Condition="$(TestFxRoot) == ''">..\..\..\..\</TestFxRoot>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(TestFxRoot)artifacts\TestAssets\</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\TestFramework\Extension.Desktop\Extension.Desktop.csproj" />
<ProjectReference Include="..\..\..\..\src\TestFramework\MSTest.Core\MSTest.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions test/E2ETests/TestAssets/DataRowTestProject/DerivedClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace DataRowTestProject
{
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class DerivedClass : BaseClass
{
[TestMethod]
[DataRow("DerivedString1")]
[DataRow("DerivedString2")]
public override void DataRowTestMethod(string a)
{
Assert.IsTrue(true);
}
}
}