In my namespace Draughts
I have two projects, Draughts
and Draughts.UnitTests
. When I try to access Draughts
methods/classes in Draughts.UnitTests
it can't find anything at all. At the top of Draughts.UnitTests
I put using Draughts
. Any ideas?
BoardUnitTests.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Draughts;
using NUnit.Framework;
namespace Draughts.UnitTests
{
public class BoardUnitTests
{
private Board GetBoard()
{
return true;
}
[Test]
public void CheckValidBoardPosition_ValidPosition_ReturnsTrue()
{
Assert.AreEqual(1, 1);
}
}
}
In the code above it can't recognize Board which is a class I have defined in Draughts
.
Here's a screenshot of my solution explorer:
Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.
I realize this is pretty old, but I came across this question while looking for a solution to my issue. For me it turned out that my Test project and the Tested project were on two different versions of the .NET Framework. I updated one, but forgot the other. Once I updated the test project to match the tested, everything worked like it should
Hope this helps the next person! :)
Probably this is related to one of these things
You don't have a reference to Draughts
on your unit test project. Right click on the test project, then Add > Reference and select the project being tested.
Classes on Draughts
are not public so you can't see them outside the project they belongs to
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With