C#C
C#3y ago
moi15moi

✅ NUnit don't execute my test

I am trying to use NUnit to test my package.
I am a total newbie in c#.

Why could visual studio ignore my test when I run them?
I saw this stackoverflow thread: https://stackoverflow.com/questions/23363073/tests-not-running-in-test-explorer?page=2&tab=scoredesc#tab-top

I tried to do the command Update-Package NUnit -reinstall in powershell, but it fails (see the image)

Here is my test file
c#
using NUnit.Framework;


namespace Data
{
    [TestFixture]
    public class CSVFactoryTest
    {
        [SetUp]
        public void Setup()
        {

        }

        [Test]
        public void CreateGroupFromCSVFile_Test()
        {
            List<Group> groups = CSVFactory.CreateGroupFromCSVFile("groups.csv");
            List<Group> expected_groups = new List<Group>
            {
                new Group(1, new Data(50, 100)),
                new Group(2, new Data(100, 150)),
                new Group(3, new Data(150, 200)),
                new Group(4, new Data(200, 250)),
                new Group(5, new Data(250, 300))
            };

            CollectionAssert.AreEqual(expected_groups, groups);
        }


        [Test]
        public void CreateDataFromCSVFile_Test()
        {
            List<Data> datas = CSVFactory.CreateDataFromCSVFile("data.csv");
            List<Data> expected_datas = new List<Data>
            {
                new Data(104, 162),
                new Data(291, 349),

            };

            CollectionAssert.AreEqual(expected_datas, datas);
        }
    }
}
image.png
image.png
Was this page helpful?