markjprice / cs11dotnet7

Repository for the Packt Publishing book titled "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals" by Mark J. Price
566 stars 206 forks source link

No instructions on how to create a unit test app #78

Closed ghost closed 1 year ago

ghost commented 1 year ago

Chapter: 04: Writing, Debugging and Testing Functions Page Number: 185 Section Title: Creating a class library that needs testing Step Number: 5 Problem to fix: There are no instructions on how to create a unit test app in VS Code Suggested solution: Add dotnet new xunit command on that step. Other useful information e.g. OS, coding tools, and so on: VS Code

markjprice commented 1 year ago

Page 185 tells them what project template to use for both Visual Studio 2022 and at the command prompt for Visual Studio Code: image Chapter 1 has step by step instructions that apply to any template, and I even repeat the standard instructions on page 185. The only difference is the template name which I give.

ghost commented 1 year ago

In the 5th step you just create an empty workspace with no files and in 6th step(VS Code) there is a reference on "CalculatorLibUnitTests.csproj" file. I can't find the step where you create the application. Is it usual console app or xunit app?

I don't find any reference on "xunit" in the 1st chapter.

I guess I am confusing something.

markjprice commented 1 year ago

In Step 1, I explain that the reader must add a Class Library/classlib project to the solution. Creating any project type is the same as creating a console. Instructions in Chapter 1 show how to create a console, not an xunit project, but as I explain in Step 1, the only difference is the project template name. For example, instead of console, enter classlib or xunit.

image

I don't know which Step 5 you mean when you say "In the 5th step you just create an empty workspace with no files". Step 5 in the VS Code steps says "In TERMINAL, confirm that you are in the CalculatorLib folder, and then enter the command to create a new class library, as shown in the following command: dotnet new console." But that already has an errata saying it should be classlib not console. And the other Step 5 says "Use your preferred coding tool to add a new xUnit Test Project [C#] / xunit project named CalculatorLibUnitTests to the Chapter04 workspace/solution." So the reader should know how to do that using dotnet new xunit because only the project type name is different and the other steps for adding the new project to the workspace are the same as for a class library or console app.

markjprice commented 1 year ago

As I say, by this point the reader has see dozens of steps like the following:

image image image

So they should know that the following is the same but with a different project template name:

image

ghost commented 1 year ago

Sorry for being unclear. By step 5 I meant the step 5 that is mentioned in this issue and on the 1st screenshot you sent. Somehow I didn't find the relations between / and "console add ". Now everything is more than clear. Thank you, Mark and sorry for taking your time.