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

Documentation - Test Explorer #1302

Closed
Pinox opened this issue Nov 28, 2024 · 6 comments
Closed

Documentation - Test Explorer #1302

Pinox opened this issue Nov 28, 2024 · 6 comments

Comments

@Pinox
Copy link

Pinox commented Nov 28, 2024

I followed the Tutorial Basics and immediately hit my first obstacle.

Test explorer in Visual Studio is not working and that is a show stopper for me. After searching online I eventually found a comment that the xunit template can be used with tunit and then the test explorer work again.

image

with project file as follows:
image

Would be great if you guys include this test explorer setup screen with the Visual Studio settings screenshot in the basics tutorial as I think a lot of people like me will be looking for this as that is what we are accustomed to using inside visual studio.

@thomhurst
Copy link
Owner

Where did you read this comment? You do not need the xunit runner. You probably just haven't turned on the testing platform mode as detailed here: https://thomhurst.github.io/TUnit/docs/tutorial-basics/running-your-tests#visual-studio

@Pinox
Copy link
Author

Pinox commented Nov 28, 2024

@thomhurst
Copy link
Owner

They're mixing xUnit and TUnit in one project, which is not supported, they will conflict with each other.

Testing platform did not work for me on its own.

Did you restart Visual Studio after?

Also, Coverlet is not supported for TUnit, you need to use: Microsoft.Testing.Extensions.CodeCoverage

@Pinox
Copy link
Author

Pinox commented Nov 28, 2024

Did you restart Visual Studio after?

No, I did not as it was already selected in my settings.

I initially got this error message but I see you are right if I now restart a new Visual Studio project with the normal packs then it works.

image

========== Starting test discovery ==========
Test framework UID: 'TUnitExtension' Version: '0.4.1.0' DisplayName: 'TUnit' Description: 'TUnit Framework for Microsoft Testing Platform'
System.IO.IOException: The device is not ready. : '000.testlog'
at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan1 buffer, Int64 fileOffset) at System.IO.Strategies.OSFileStreamStrategy.Write(ReadOnlySpan1 buffer)
at System.IO.Strategies.OSFileStreamStrategy.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Strategies.BufferedFileStreamStrategy.Flush(Boolean flushToDisk)
at Microsoft.VisualStudio.TestStorage.TestLog.WriteLogEntry(LogEntry logEntry)
at Microsoft.VisualStudio.TestStorage.TestLog.Append(TestBaseRecord testRecord)
at Microsoft.VisualStudio.TestStorage.TestStore.AddToLog(TestBaseRecord record)
at Microsoft.VisualStudio.TestStorage.TestStore.Add(TestBaseRecord record, Boolean onlyAddIfNew)
at Microsoft.VisualStudio.TestWindow.Host.TestRunSessionBase.AddTestCases(ICollection1 testCaseRecords) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.AddRemoteTestCaseRecords(IEnumerable1 testCases)
at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestsDiscovered(IEnumerable1 testsDiscovered) at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging[TArg](IInternalLogger log, Action1 action, TArg arg, Boolean shouldThrow)
System.IO.IOException: The device is not ready. : '\TestStore\0\000.testlog'
at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan1 buffer, Int64 fileOffset) at System.IO.Strategies.OSFileStreamStrategy.Write(ReadOnlySpan1 buffer)
at System.IO.Strategies.OSFileStreamStrategy.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Strategies.BufferedFileStreamStrategy.Flush(Boolean flushToDisk)
at Microsoft.VisualStudio.TestStorage.TestLog.WriteLogEntry(LogEntry logEntry)
at Microsoft.VisualStudio.TestStorage.TestLog.Append(TestBaseRecord testRecord)
at Microsoft.VisualStudio.TestStorage.TestStore.AddToLog(TestBaseRecord record)
at Microsoft.VisualStudio.TestStorage.TestStore.Add(TestBaseRecord record, Boolean onlyAddIfNew)
at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnDiscoveryCompletedForContainer(TestContainerRecord container, IEnumerable1 activeEnvironments) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnDiscoveryCompleted(IEnumerable1 containersSentForDiscovery, IEnumerable`1 activeEnvironments)
at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.DiscoverTestsAsync(DiscoverTestsRequest request, TestStore testStore, VsTestRunSession runSession, CancellationToken cancellationToken)
at Microsoft.VisualStudio.TestWindow.Host.TestWindowStoreService.<>c__DisplayClass42_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---

@thomhurst
Copy link
Owner

Glad it's working now

@Arthri
Copy link

Arthri commented Dec 1, 2024

Also, Coverlet is not supported for TUnit, you need to use: Microsoft.Testing.Extensions.CodeCoverage

For what it's worth, coverlet.console seems to work with TUnit. But coverlet.msbuild requires a few tweaks, which I've detailed in the issue I wrote coverlet-coverage/coverlet#1715

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

No branches or pull requests

3 participants