Repository navigation
Add Motus.Testing.MSTest.v4 for MSTest 4 - #38
Merged
Merged
Conversation
Motus.Testing.MSTest is built against MSTest 3, and MSTest 4 renamed the assemblies its types live in. MSTest recognizes an inherited [TestInitialize] and [TestCleanup] by the exact identity of its attribute types, so a project on MSTest 4 deriving from MotusTestBase had its setup and cleanup ignored (MSTEST0082), failed to compile as soon as it touched TestContext (CS0012), and could not be discovered at all. MotusTestMethodAttribute also overrode Execute, which MSTest 4 replaced with ExecuteAsync. NuGet chooses a package's assets by target framework, never by the version of another dependency, so one package cannot carry a build for each MSTest major. The new Motus.Testing.MSTest.v4 package compiles the same source files, linked rather than copied, against MSTest.TestFramework 4.0.0, with the same namespace and types, so moving a suite to MSTest 4 is a package reference change. The only source that differs is MotusTestMethodAttribute, which under MSTEST_V4 overrides ExecuteAsync and passes the caller's file and line to MSTest, taking them from the wrapped attribute when [MotusTestClass] wraps one. The name follows Microsoft.Playwright.MSTest.v4. Motus.Testing.MSTest is unchanged for MSTest 3 users, but now declares MSTest.TestFramework [3.5.2, 4.0.0), so a project on MSTest 4 that references it gets NU1608 at restore instead of tests that silently never get a page. A new test project on MSTest 4.5.1, set up as dotnet new mstest sets it up, runs the issue's sample (TestContext.WriteLine in a MotusTestBase subclass) against a browser, runs the retry through MSTest 4 itself, and treats MSTEST0082 as an error. The release workflow packs the new package, and the docs and package READMEs say which package goes with which MSTest. Fixes #19 Signed-off-by: Torrey Betts <torrey.betts@gmail.com>
SummarySummary
CoverageMotus - 80.7%
Motus.Abstractions - 87.7%
Motus.Analyzers - 91%
Motus.Cli - 82.1%
Motus.Codegen - 89.8%
Motus.Mcp - 91.9%
Motus.Mcp.Http - 98.6%
Motus.Recorder - 77.8%
Motus.Testing - 75.4%
Motus.Testing.MSTest - 79%
Motus.Testing.MSTest.v4 - 22.8%
Motus.Testing.xUnit - 63.6%
|
Brings the branch up to date with the locator, frame, keyboard and installed-browser changes that landed on main, so CI runs the MSTest 4 package against the code it will ship with. Signed-off-by: Torrey Betts <torrey.betts@gmail.com>
TorreyBetts
added a commit
that referenced
this pull request
Oct 24, 2026
TorreyBetts
added a commit
that referenced
this pull request
Oct 24, 2026
Brings in #31, #32, #33, #35, #36, #37, #38 and #40. Everything merged cleanly; the frame navigation handlers in Page.Events.cs sit next to the execution context tracking from #33 without touching it, and same-document navigations still leave execution contexts alone. Signed-off-by: Torrey Betts <torrey.betts@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motus.Testing.MSTestis built against MSTest 3.5.2, and MSTest 4 renamed the assemblies its types live in (TestContextand the lifecycle attributes moved fromMicrosoft.VisualStudio.TestPlatform.TestFramework(.Extensions)14.0.0.0 toMSTest.TestFramework(.Extensions)). MSTest recognizes an inherited[TestInitialize]and[TestCleanup]by the exact identity of its own attribute types, so on MSTest 4 a class deriving fromMotusTestBasehad its setup and cleanup ignored (MSTEST0082), failed to compile once it touchedTestContext(CS0012), and could not be discovered.MotusTestMethodAttributealso overrodeExecute, which MSTest 4 replaced withExecuteAsync. I reproduced all three with the issue's sample before changing anything.The change
A second package,
Motus.Testing.MSTest.v4. It compiles the same source files asMotus.Testing.MSTest(linked fromsrc/Motus.Testing.MSTest, not copied) againstMSTest.TestFramework4.0.0, the lowest stable 4.x, so it works with any 4.x the test project picks. The namespace and types are the same, so moving a suite to MSTest 4 is a package reference change and nothing in the tests. The name followsMicrosoft.Playwright.MSTest.v4, which people coming from Playwright will recognize.The only source that differs between the two builds is
MotusTestMethodAttribute, under#if MSTEST_V4:ExecuteAsyncinstead ofExecute, with the same retry rule (only a lost browser is retried);[CallerFilePath]/[CallerLineNumber]and passes them to MSTest, which uses them to navigate to the test's source (MSTEST0057);[MotusTestClass]uses to wrap another attribute takes the source location from the wrapped attribute, so tests in a[MotusTestClass]keep theirs.MotusTestBaseandMotusTestClassAttributecompile unchanged against MSTest 4.MotusTestBase's failure detection is untouched.Motus.Testing.MSTestnow accepts MSTest 3 only. Its dependency isMSTest.TestFramework [3.5.2, 4.0.0). MSTest 3 users see no difference. A project on MSTest 4 that references it now getsNU1608at restore, naming the version conflict, instead of tests that quietly never get a page.Why not one package for both majors. NuGet chooses a package's
libassets by target framework only, never by the version of another dependency, so a single package cannot carry an MSTest 3 build and an MSTest 4 build for the same TFM. The only way to get one would be an MSBuild targets file that inspects the resolved MSTest version and swaps the reference after restore. That breaks the normal NuGet model (onelibper TFM, honest dependency metadata), is fragile in IDE design-time builds and under central package management, and adds a moving part to every consumer's build. Moving the existing package to MSTest 4 was also rejected, since it would break every current user on MSTest 3.Behavior changes
Motus.Testing.MSTest.v4for MSTest 4 projects, with the same namespace and API asMotus.Testing.MSTest.Motus.Testing.MSTestnow declaresMSTest.TestFramework>= 3.5.2 && < 4.0.0. A project on MSTest 4 that references it gets aNU1608restore warning (an error underTreatWarningsAsErrors). Such a project could not run Motus tests before this change either.Motus.Testing.MSTest.v4,MotusTestMethodAttribute()takes optionalcallerFilePath/callerLineNumberparameters (filled in by the compiler) and overridesExecuteAsync. That is MSTest 4's API; the MSTest 3 package is unchanged.Tests
tests/Motus.Testing.MSTest.v4.Testson MSTest 4.5.1, set up the waydotnet new mstestsets it up (theMSTestmetapackage,[assembly: Parallelize]), withMSTEST0082as an error so a base class built against the wrong major fails the build. It covers:TestContext.WriteLinethenPage.GotoAsyncin aMotusTestBasesubclass), plain and under[MotusTestClass](Integration, needs a browser);MotusTestBase's lifecycle attributes andTestContexthaving MSTest 4's type identity;ExecuteAsync, including a real[MotusTestMethod]run by MSTest 4 itself, and source locations being kept.CS0012andMSTEST0082errors, and restore reportsNU1608.Motus.TestsMotus.Tests.Testing(MSTest 3 base class, retry and lazy launch) 40/40 each.Motus.Testing.MSTest.v4package: it builds, is discovered, and passes withstartingin the output. The same project againstMotus.Testing.MSTestgetsNU1608andCS0012.Fixes #19