Problem with cli and testing

I don’t understand how testing works in VSCode, although I read the help file. For example the CarsAssemble assignment.
I tried ‘dotnet CarsAssembleTests.cs’ in the integrated terminal. this wasn’t working. What am I doing wrong?
Downloading and submitting is working fine.

Testing on the C# track | Exercism's Docs has instructions on running tests. Make sure you first follow the setup instructions, Installing C# locally | Exercism's Docs

Additionally, the VS Code Docs has this setup guide for C#, as well as these extensions docs, which walk through how to work with the C# Dev Kit for VS Code.

There are also MS Docs for dotnet-test.

Thanks for the feedback. I read the documentation you provided, but I am still stuck.
In this example, am I supposed to use the command like that:
dotnet test CarsAssemble.csproj ?
If I don’t specify a file, I get the following error:
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
I think I am missing something. Any idea what I’m doing wrong?

The docs say, “To run the tests, execute the following command: dotnet test”. No other arguments needed.

Did you use exercism download to get the files? Are you in the exercise directory? What happens when you run exactly that command?

Hi I used the CLI-tool to download the exercises.
In VSCode, I am in the following folder: C:\Users\Torben\Exercism\csharp\cars-assemble>
So I am in the exercise directory. When I run the command dotnet test I get the following result:

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.

Submitting with the CLI tool works fine. Just the testing in VSCode fails.

What does dir output?

This implies that somehow there are multiple projects in that directory.

Result of dir:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        21.04.2024     18:43                .exercism
d-----        21.04.2024     18:46                bin
d-----        21.04.2024     18:46                obj
-a----        22.04.2024     20:02           1615 cars-assemble.sln
-a----        21.04.2024     19:40            828 CarsAssemble.cs
-a----        21.04.2024     18:43            443 CarsAssemble.csproj
-a----        21.04.2024     18:43           3044 CarsAssembleTests.cs
-a----        21.04.2024     18:43           2157 HELP.md
-a----        21.04.2024     18:43           1634 HINTS.md
-a----        21.04.2024     18:43           3530 README.md

But, just to be sure I checked testing out with another project. Here it seems to work:

PS C:\Users\Torben\Exercism\csharp\bob> dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  Bob -> C:\Users\Torben\Exercism\csharp\bob\bin\Debug\net8.0\Bob.dll
Test run for C:\Users\Torben\Exercism\csharp\bob\bin\Debug\net8.0\Bob.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:01.59]     BobTests.Using_acronyms_in_regular_speech [SKIP]
[xUnit.net 00:00:01.59]     BobTests.Statement_containing_question_mark [SKIP] 
[xUnit.net 00:00:01.59]     BobTests.Non_question_ending_with_whitespace [SKIP]
[xUnit.net 00:00:01.59]     BobTests.Shouting_with_no_exclamation_mark [SKIP]  
[xUnit.net 00:00:01.59]     BobTests.Alternate_silence [SKIP]
[xUnit.net 00:00:01.59]     BobTests.Multiple_line_question [SKIP]
[xUnit.net 00:00:01.59]     BobTests.Silence [SKIP]
[xUnit.net 00:00:01.59]     BobTests.Question_with_no_letters [SKIP]
[xUnit.net 00:00:01.59]     BobTests.Prolonged_silence [SKIP]
  Skipped BobTests.Using_acronyms_in_regular_speech [1 ms]
  Skipped BobTests.Statement_containing_question_mark [1 ms]
  Skipped BobTests.Non_question_ending_with_whitespace [1 ms]
  Skipped BobTests.Shouting_with_no_exclamation_mark [1 ms]
  Skipped BobTests.Alternate_silence [1 ms]
  Skipped BobTests.Multiple_line_question [1 ms]
  Skipped BobTests.Silence [1 ms]
  Skipped BobTests.Question_with_no_letters [1 ms]
  Skipped BobTests.Prolonged_silence [1 ms]
[xUnit.net 00:00:01.61]     BobTests.Asking_a_question [SKIP]
[xUnit.net 00:00:01.61]     BobTests.Forceful_question [SKIP]
[xUnit.net 00:00:01.61]     BobTests.Ending_with_whitespace [SKIP]
[xUnit.net 00:00:01.61]     BobTests.Shouting_gibberish [SKIP]
[xUnit.net 00:00:01.61]     BobTests.Shouting_numbers [SKIP]
[xUnit.net 00:00:01.61]     BobTests.Stating_something [FAIL]
[xUnit.net 00:00:01.61]     BobTests.Starting_with_whitespace [SKIP]
[xUnit.net 00:00:01.61]     BobTests.Shouting [SKIP]
[xUnit.net 00:00:01.61]     BobTests.Prattling_on [SKIP]
  Skipped BobTests.Asking_a_question [1 ms]
  Skipped BobTests.Forceful_question [1 ms]
  Skipped BobTests.Ending_with_whitespace [1 ms]
  Skipped BobTests.Shouting_gibberish [1 ms]
  Skipped BobTests.Shouting_numbers [1 ms]
  Failed BobTests.Stating_something [1 ms]
  Error Message:
   System.NotImplementedException : You need to implement this function.
  Stack Trace:
     at Bob.Response(String statement) in C:\Users\Torben\Exercism\csharp\bob\Bob.cs:line 7
   at BobTests.Stating_something() in C:\Users\Torben\Exercism\csharp\bob\BobTests.cs:line 8
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
  Skipped BobTests.Starting_with_whitespace [1 ms]
  Skipped BobTests.Shouting [1 ms]
  Skipped BobTests.Prattling_on [1 ms]
[xUnit.net 00:00:01.62]     BobTests.Non_letters_with_question [SKIP]
[xUnit.net 00:00:01.62]     BobTests.Shouting_with_special_characters [SKIP]
[xUnit.net 00:00:01.62]     BobTests.Asking_gibberish [SKIP]
[xUnit.net 00:00:01.62]     BobTests.Other_whitespace [SKIP]
[xUnit.net 00:00:01.62]     BobTests.No_letters [SKIP]
[xUnit.net 00:00:01.62]     BobTests.Asking_a_numeric_question [SKIP]
[xUnit.net 00:00:01.62]     BobTests.Talking_forcefully [SKIP]
  Skipped BobTests.Non_letters_with_question [1 ms]
  Skipped BobTests.Shouting_with_special_characters [1 ms]
  Skipped BobTests.Asking_gibberish [1 ms]
  Skipped BobTests.Other_whitespace [1 ms]
  Skipped BobTests.No_letters [1 ms]
  Skipped BobTests.Asking_a_numeric_question [1 ms]
  Skipped BobTests.Talking_forcefully [1 ms]

Failed!  - Failed:     1, Passed:     0, Skipped:    24, Total:    25, Duration: 32 ms - Bob.dll (net8.0)

I didn’t work this problem yet, so I expected it to fail.

I don’t know why it didn’t work with the CarsAssemble project. Maybe I changed some file which broke testing. Difficult to say.

Anyway, thanks for helping me so far.

Could you remove cars-assemble.sln and try running dotnet test again? Our exercises don’t supply solution files.

That worked! After removing the file you mentioned, I got this result:

PS C:\Users\Torben\Exercism\csharp\cars-assemble> dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  CarsAssemble -> C:\Users\Torben\Exercism\csharp\cars-assemble\bin\Debug\net8.0\CarsAssemble.dll
Test run for C:\Users\Torben\Exercism\csharp\cars-assemble\bin\Debug\net8.0\CarsAssemble.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:    18, Skipped:     0, Total:    18, Duration: 32 ms - CarsAssemble.dll (net8.0)
PS C:\Users\Torben\Exercism\csharp\cars-assemble>
1 Like

Great. Congrats on passing the tests.

1 Like