Unit Testing in Test Explorer says "not run" despite producing no errors and only warning messages

huangapple go评论130阅读模式
英文:

Unit Testing in Test Explorer says "not run" despite producing no errors and only warning messages

问题

以下是代码的翻译部分:

初学者在这里 - 我正在尝试测试以下代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace PersonCreator
    {
        public class Person
        {
            public string Name { get; set; } = "";
            public DateTime BirthDate { get; set; } = new DateTime(1900, 1, 1);
            public double Height { get; set; } = 0.0;
            public Boolean IsMarried { get; set; } = false;
            public int NoOfChildren { get; set; } = 0;
    
            public Person(string name, DateTime birthdate, double height, Boolean isMarried, int noOfChildren)
            {
                this.Name = name;   
                this.BirthDate = birthdate;
                this.Height = height;
                this.IsMarried = isMarried;
                this.NoOfChildren = noOfChildren;
            }
    
            public string MakeTitle()
            {
                string title = ($"{Name};{BirthDate};{Height};{IsMarried};{NoOfChildren}");
                return title;
            }
        }
    }

使用以下单元测试:

    using PersonCreator;
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void CheckPersonConstructor()
        {
            // #### ARRANGE ####
            Person person = new Person("John Doe", new DateTime(1975, 8, 24), 175.9, true, 3);
    
            // #### ACT ####
            string title = person.MakeTitle();
    
            // #### ASSERT ####
            Assert.AreEqual("John Doe;24-08-1975 00:00:00;175,9;True;3", title);
           }
    }

请注意,上述内容中的 " 是 HTML 实体,代表双引号字符 "。在实际代码中,你应该使用双引号而不是 "

英文:

Beginner here - I am trying to test the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PersonCreator
{
    public class Person
    {
        public string Name { get; set; } = "";
        public DateTime BirthDate { get; set; } = new DateTime(1900, 1, 1);
        public double Height { get; set; } = 0.0;
        public Boolean IsMarried { get; set; } = false;
        public int NoOfChildren { get; set; } = 0;

        public Person(string name, DateTime birthdate, double height, Boolean isMarried, int noOfChildren)
        {
            this.Name = name;   
            this.BirthDate = birthdate;
            this.Height = height;
            this.IsMarried = isMarried;
            this.NoOfChildren = noOfChildren;
        }

        public string MakeTitle()
        {
            string title = ($"{Name};{BirthDate};{Height};{IsMarried};{NoOfChildren}");
            return title;
        }
    }
}

With the following unit test:

using PersonCreator;
[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void CheckPersonConstructor()
    {
        // #### ARRANGE ####
        Person person = new Person("John Doe", new DateTime(1975, 8, 24), 175.9, true, 3);

        // #### ACT ####
        string title = person.MakeTitle();

        // #### ASSERT ####
        Assert.AreEqual("John Doe;24-08-1975 00:00:00;175,9;True;3", title);


       }
}

Running the Test Explorer in Visual Studio simply says "1 not run test" and running "dotnet test" provides the following errors:
Unit Testing in Test Explorer says "not run" despite producing no errors and only warning messages

What could be the issue for the test not running and the warning messages?

答案1

得分: 1

问题已解决,已更新NuGet包。

EDIT: 包含了包的图片。
Unit Testing in Test Explorer says "not run" despite producing no errors and only warning messages

英文:

Problem is solved, updated the NuGet packages

EDIT: Included the picture of the packages.
Unit Testing in Test Explorer says "not run" despite producing no errors and only warning messages

huangapple
  • 本文由 发表于 2023年3月8日 18:02:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75671625.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定