C
C#8mo ago
Caeden

❔ Creating a github workflow to test solution (MSTest)

I have this solution https://github.com/caedenph/wa-tor I have two projects within it, the base one is the implementation of this algorithm, and the other project is within WaTorTests/. How can I link the tests in WaTorTests/ to the root project so that I can run dotnet test? For context:
> dotnet test
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
> dotnet test WaTorTests
Determining projects to restore...
Nothing to do. None of the projects specified contain packages to restore.
> dotnet test
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
> dotnet test WaTorTests
Determining projects to restore...
Nothing to do. None of the projects specified contain packages to restore.
23 Replies
Caeden
Caeden8mo ago
@V.EINA Jaken Apologies for not responding earlier, started by just rewriting the code in c#. You mentioned the c# file naming conventions (for the .csproj and .sln) should be valid identifiers? What do you mean? What works better for those files, Wa-Tor or WaTor?
Tvde1
Tvde18mo ago
you can cd into the folder with github actions, or add WaTorTests to your dotnet command
Caeden
Caeden8mo ago
How do I add waTorTests to my dotnet command?
Tvde1
Tvde18mo ago
you already typed it
Caeden
Caeden8mo ago
So far I haven't been able to test from cmd at all
Tvde1
Tvde18mo ago
ah wait it doesn't see any test projects
Caeden
Caeden8mo ago
dotnet test WaTorTests should run the 14 tests it ran nothing afaik
Tvde1
Tvde18mo ago
Are the test projects in your SLN?
Caeden
Caeden8mo ago
no?
Tvde1
Tvde18mo ago
hmmm might be some .NET framework 4.7 trickery I've only done this with modern .NET versions
Caeden
Caeden8mo ago
damn
Tvde1
Tvde18mo ago
is there a reason you're on a very old .NET version?
Caeden
Caeden8mo ago
yeah, the exam board/schools use theis version dont you love outdated system archichtecture
Tvde1
Tvde18mo ago
ah I feel sorry for you :/
Caeden
Caeden8mo ago
theres got to be a way to test from cmd tho
JakenVeina
JakenVeina8mo ago
one of those is a valid name you could give to something in C# code, and one is not
Caeden
Caeden8mo ago
Got it Can I just rename the Wa-Tor or will this break something
JakenVeina
JakenVeina8mo ago
what's named that, currently?
Caeden
Caeden8mo ago
the .sln
JakenVeina
JakenVeina8mo ago
renaming the file won't affect anything that won't change the solution's "name" per se but it also isn't hurting anything
Caeden
Caeden8mo ago
Okay I showed the dotnet test above, do you know how I can link the projects?
arion
arion8mo ago
The dotnet cli isn't compatible with .NET Framework¹ iirc Though you could try running mstest like what a person said in on this StackOverflow post I tried to run your repo's tests using & 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\MSTest.exe' /testcontainer:"WaTorTests.dll" but originally failed After checking a bit, removing the nuget package MSTest.TestFramework and replacing it with MicrosoftVisualStudioQualityToolsUnitTestFramework seemed to fix it (Though doing so makes testing via an IDE break) ! Please note, that the nuget package above is not actually from microsoft but rather an author called "juniho", adding unverified nuget packages can lead to malware being executed. that being said, the nuget package has 500k downloads and has been up since 2020, its likely not that. Anyways, this is the CLI Output after changing to the new nuget package:
& 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\MSTest.exe' /testcontainer:"WaTorTests.dll"
Microsoft (R) Test Execution Command Line Tool Version 17.0.33906.96
Copyright (c) Microsoft Corporation. All rights reserved.

MSTest.exe runner is legacy. Please migrate to vstest.console.exe (https://aka.ms/vstestconsole) or dotnet test (https://aka.ms/dotnettest) instead. You can use /nologo switch to suppress this message.
Loading WaTorTests.dll...
TestTypes\37e36796-fb51-4610-8d5c-e00ceaa68b9f could not be loaded because the TIP could not be instantiated for the following reason(s): System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.Tips.WebLoadTest.Tip, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.QualityTools.Tips.WebLoadTest.Tip, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at Microsoft.VisualStudio.TestTools.TestManagement.TipDelayLoader.LoadTip()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Starting execution...

Results Top Level Tests
------- ---------------
Passed WaTorTests.EntityTests.EntityInitialization_Predator_CorrectValues
Passed WaTorTests.EntityTests.EntityInitialization_Prey_CorrectValues
Passed WaTorTests.EntityTests.EntityResetReproductionTime_Predator_ResetsTo20
Passed WaTorTests.EntityTests.EntityResetReproductionTime_Prey_ResetsTo5
Passed WaTorTests.WaTorTests.WaTorAddEntity_AddsEntity
Passed WaTorTests.WaTorTests.WaTorBalancePredatorsAndPrey_BalancesEntities
Passed WaTorTests.WaTorTests.WaTorGetEntities_ReturnsEntities
Passed WaTorTests.WaTorTests.WaTorGetSurroundPrey_GetsSurroundingPrey
Passed WaTorTests.WaTorTests.WaTorMoveAndReproduce_DoesReproduce
Passed WaTorTests.WaTorTests.WaTorPerformPredatorActions_EatsPrey
Passed WaTorTests.WaTorTests.WaTorRun_Entities_Change
Passed WaTorTests.WaTorTests.WaTorSetPlanet_TestOne
Passed WaTorTests.WaTorTests.WaTorSetPlanet_TestTwo
13/13 test(s) Passed

Summary
-------
Test Run Completed.
Passed 13
----------
Total 13
Results file: C:\Users\Dawn\temp\Wa-Tor\WaTorTests\bin\Release\TestResults\Dawn_DAWN 2023-10-09 00_25_40.trx
Test Settings: Default Test Settings
& 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\MSTest.exe' /testcontainer:"WaTorTests.dll"
Microsoft (R) Test Execution Command Line Tool Version 17.0.33906.96
Copyright (c) Microsoft Corporation. All rights reserved.

MSTest.exe runner is legacy. Please migrate to vstest.console.exe (https://aka.ms/vstestconsole) or dotnet test (https://aka.ms/dotnettest) instead. You can use /nologo switch to suppress this message.
Loading WaTorTests.dll...
TestTypes\37e36796-fb51-4610-8d5c-e00ceaa68b9f could not be loaded because the TIP could not be instantiated for the following reason(s): System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.Tips.WebLoadTest.Tip, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.QualityTools.Tips.WebLoadTest.Tip, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at Microsoft.VisualStudio.TestTools.TestManagement.TipDelayLoader.LoadTip()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Starting execution...

Results Top Level Tests
------- ---------------
Passed WaTorTests.EntityTests.EntityInitialization_Predator_CorrectValues
Passed WaTorTests.EntityTests.EntityInitialization_Prey_CorrectValues
Passed WaTorTests.EntityTests.EntityResetReproductionTime_Predator_ResetsTo20
Passed WaTorTests.EntityTests.EntityResetReproductionTime_Prey_ResetsTo5
Passed WaTorTests.WaTorTests.WaTorAddEntity_AddsEntity
Passed WaTorTests.WaTorTests.WaTorBalancePredatorsAndPrey_BalancesEntities
Passed WaTorTests.WaTorTests.WaTorGetEntities_ReturnsEntities
Passed WaTorTests.WaTorTests.WaTorGetSurroundPrey_GetsSurroundingPrey
Passed WaTorTests.WaTorTests.WaTorMoveAndReproduce_DoesReproduce
Passed WaTorTests.WaTorTests.WaTorPerformPredatorActions_EatsPrey
Passed WaTorTests.WaTorTests.WaTorRun_Entities_Change
Passed WaTorTests.WaTorTests.WaTorSetPlanet_TestOne
Passed WaTorTests.WaTorTests.WaTorSetPlanet_TestTwo
13/13 test(s) Passed

Summary
-------
Test Run Completed.
Passed 13
----------
Total 13
Results file: C:\Users\Dawn\temp\Wa-Tor\WaTorTests\bin\Release\TestResults\Dawn_DAWN 2023-10-09 00_25_40.trx
Test Settings: Default Test Settings
The following StackOverflow post shows how you can run mstest.exe through github actions for your workflow. Alternate options i've found is downloading visual studio build tools and using their vstest which too has their own respective github actions workflow
Accord
Accord8mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.