Since I can unit test, I try to create the project from the class I wanted to practice with, but I get an error:
The type or namespace name 'TestMethodAttribute' could not be found(are you missing a using directive or an assembly reference?
This is the class that has been generated from the class I want to test:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp2.Tests
{
[TestClass()]
public class AccountTests
{
[TestMethod()]
public void WithdrawTest()
{
Assert.Fail();
}
}
}
I also get the error that the namespace VisualStudio
does not exist. I would appreciate any help.
I am using Visual Studio as development environment.
Here is the structure of the solution, with the test project that I have generated, with the class Account
that is the one that I want to test included in it.
In this case AccountTest
the class is renamed.
This is how I created the test:
I have left the default for the rest of the configuration:
Based on the image you share, it doesn't seem like you've added the correct project type. The icon for a unit test project is different. The project you present there appears to be a class library, and not a unit test project. I share with you an image of the creation of a new project in
Visual Studio 2019
, where you can see the project icon (from your image I see that we have close or similar versions):