-
Notifications
You must be signed in to change notification settings - Fork 692
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
Change Apex tests from Xunit to MSTest #4306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start with few comments. In general looks good.
@@ -113,6 +113,8 @@ | |||
<PackageReference Update="xunit" Version="$(XunitVersion)" /> | |||
<PackageReference Update="xunit.runner.visualstudio" Version="$(XunitVersion)" /> | |||
<PackageReference Update="Xunit.StaFact" Version="0.2.9" /> | |||
<PackageReference Update="MSTest.TestAdapter" Version="2.1.1" /> | |||
<PackageReference Update="MSTest.TestFramework" Version="2.1.1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this version 2.2.1 is chosen? It looks latest version is 2.2.7.
{ | ||
public NetCoreProjectTestCase(VisualStudioHostFixtureFactory visualStudioHostFixtureFactory, ITestOutputHelper output) | ||
: base(visualStudioHostFixtureFactory, output) | ||
private const int Timeout = 5 * 60 * 1000; // 5 minutes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this SharedVisualStudioHostTestClass.cs
it looks repeated.
[NuGetWpfTheory] | ||
[MemberData(nameof(GetNetCoreTemplates))] | ||
public void CreateNetCoreProject_RestoresNewProject(ProjectTemplate projectTemplate) | ||
[TestMethod] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to change NuGetWpfTheory
to MSTest attribute or created new one?
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] |
If I am reading xunit/xunit#217 (comment) from the |
{ | ||
logger.LogInformation("Creating test context"); | ||
Trace.WriteLine("Creating test context"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How we're monitoring this message? If I remember correctly then it writes to VS "Output window". How do we check this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response..
I think logger.LogInformation
is not writing to VS "Output window", but print log to the testing console.
If checking the following code:
1.ApexTestContext accept ILogger logger in the constructor at here
2.One example of new a ApexTestContext object is this
3.And the XunitLogger is from here
4.If checking the constructor of XunitLogger, it's here
We need the ITestOutputHelper
as in Xunit, there seems no other way to print log in the testing console.
Pls check https://xunit.net/docs/capturing-output
For MSTest, we could use Trace.WriteLine to log, the output is written to an instance of DefaultTraceListener.
And in the testing, we could see the trace is shown when test failed in this build
I just running an apex test locally with a timeout and disabling parallel execution of tests. Unfortunately, tests didn't stop after timeout. |
Thanks @kartheekp-ms ! I checked the issue, too. But there are two Apex test classes IVsServicesTestCase and NetCoreProjectTestCase, having not async test cases, which will still not be able to timed out if using Xunit. |
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
Found a related tickets I raised at that time: https://dev.azure.com/mseng/AzureDevOps/_workitems/edit/1885534 |
Bug
Fixes: https://github.com/nuget/client.engineering/issues/852
Regression? Last working version:
Description
Background
Since Xunit is not able to timeout individual test (comment), in order to time out individual Apex tests, change Apex tests from Xunit to MSTest.
1.Change Apex test from Xunit to MSTest:
Theory
->TestMethod
,InlineData
->DataRow
,Skip
->Ignore
, etc.Timeout
attribute for each Apex testsPR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation