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

Add ability to ignore specific test cases #4457

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Dec 27, 2024

Fixes #1411

@Youssef1313 Youssef1313 requested a review from Copilot December 27, 2024 09:27

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 19 changed files in this pull request and generated no comments.

Files not reviewed (14)
  • src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt: Language not supported
  • src/TestFramework/TestFramework/Attributes/TestMethod/TestClassAttribute.cs: Evaluated as low risk
  • src/TestFramework/TestFramework/Attributes/DataSource/DynamicDataAttribute.cs: Evaluated as low risk
  • src/Adapter/MSTest.TestAdapter/ObjectModel/UnitTestElement.cs: Evaluated as low risk
  • src/TestFramework/TestFramework/Attributes/DataSource/DataRowAttribute.cs: Evaluated as low risk
  • src/Adapter/MSTest.TestAdapter/ObjectModel/TestMethod.cs: Evaluated as low risk
  • src/Adapter/MSTest.TestAdapter/Execution/UnitTestRunner.cs: Evaluated as low risk
  • src/Adapter/MSTest.TestAdapter/Extensions/TestCaseExtensions.cs: Evaluated as low risk
  • src/Adapter/MSTest.TestAdapter/Extensions/TestResultExtensions.cs: Evaluated as low risk
  • src/Adapter/MSTest.TestAdapter/Discovery/TypeEnumerator.cs: Evaluated as low risk
  • test/UnitTests/MSTestAdapter.UnitTests/Execution/TestExecutionManagerTests.cs: Evaluated as low risk
  • src/Adapter/MSTest.TestAdapter/Constants.cs: Evaluated as low risk
  • test/UnitTests/MSTestAdapter.UnitTests/Discovery/TypeEnumeratorTests.cs: Evaluated as low risk
  • src/TestFramework/TestFramework/Attributes/TestMethod/TestResult.cs: Evaluated as low risk
Comments suppressed due to low confidence (4)

src/Adapter/MSTest.TestAdapter/Execution/TestMethodRunner.cs:171

  • Ensure that tests are added to cover the new functionality of ignoring specific test cases based on the TestDataSourceIgnoreReason.
if (_test.TestDataSourceIgnoreReason is not null)

src/TestFramework/TestFramework/Attributes/TestMethod/TestMethodAttribute.cs:56

  • Ensure that the new Ignore property is covered by tests. The TODO in the pull request description indicates that tests are yet to be added.
public string? Ignore { get; set; }

src/Adapter/MSTest.TestAdapter/Execution/TestClassInfo.cs:571

  • The new behavior of ignoring the class cleanup should be covered by tests. Ensure that tests cover both TestDataSourceUnfoldingStrategy.Unfold and TestDataSourceUnfoldingStrategy.Fold.
if (ClassAttribute.Ignore is null &&

src/Adapter/MSTest.TestAdapter/Execution/TestClassInfo.cs:583

  • The new behavior of ignoring the class cleanup should be covered by tests. Ensure that tests cover both TestDataSourceUnfoldingStrategy.Unfold and TestDataSourceUnfoldingStrategy.Fold.
if (ClassAttribute.Ignore is null &&
/// <summary>
/// Specifies the capability of a test data source to be ignored and define the ignore reason.
/// </summary>
public interface ITestDataSourceIgnoreCapability
Copy link
Member

Choose a reason for hiding this comment

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

Could it be worth making this one more generic (not linked to data sources) so we can apply it to test methods and test classes too?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Evangelink The impl is quite different, at least currently. For example, for specific test cases, we need to have a VSTest property for that to restore the associated ignore message. But we don't need that for when it's the whole test method or test class being ignored.

Comment on lines +117 to +119
/// <summary>
/// Gets or sets a reason to ignore this dynamic data source. Setting the property to non-null value will ignore the dynamic data source.
/// </summary>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <summary>
/// Gets or sets a reason to ignore this dynamic data source. Setting the property to non-null value will ignore the dynamic data source.
/// </summary>
/// <inheritdoc />

Copy link
Member Author

Choose a reason for hiding this comment

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

I was intentionally not inheriting as I'm adjusting the wording a little bit for the specific concrete implementation. It's not super important though as the wording from the interface should still be clear enough for the concrete implementations.

Comment on lines +56 to +58
/// <summary>
/// Gets or sets a reason to ignore the specific test case. Setting the property to non-null value will ignore the test case.
/// </summary>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <summary>
/// Gets or sets a reason to ignore the specific test case. Setting the property to non-null value will ignore the test case.
/// </summary>
/// <inheritdoc />

// This is closest to ignore. This enum doesn't have a value specific to Ignore.
// It may be a better idea to add a value there, but the enum is public and we need to think more carefully before adding the API.
// For now, TestResultExtensions.ToUnitTestResults method will convert this to Ignored value of ObjectModel enum when IgnoreReason is non-null.
Outcome = UTF.UnitTestOutcome.NotRunnable,
Copy link
Member

Choose a reason for hiding this comment

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

It's probably good to have more states but I will have a closer look later.

Copy link
Member Author

@Youssef1313 Youssef1313 Dec 29, 2024

Choose a reason for hiding this comment

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

Sure. Let's discuss later

@Youssef1313
Copy link
Member Author

@Evangelink This doesn't yet implement a new type that can be specialized under IEnumerable<object[]>. I assume this can come in future? If not, we can discuss the design and I'll implement in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Ignore/Skip test or test case
2 participants