c# – 在NUnit参数化测试中没有找到合适的构造函数
发布时间:2020-12-15 17:37:44 所属栏目:百科 来源:网络整理
导读:见下面的测试夹具: using System;using System.Collections.Generic;using System.Linq;using System.Text;using NUnit.Framework;/// summary/// Tests relating to Harry Potter/// /summary[TestFixture("Dumbledore")]public class HarryPotterTests{ p
见下面的测试夹具:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using NUnit.Framework; /// <summary> /// Tests relating to Harry Potter /// </summary> [TestFixture("Dumbledore")] public class HarryPotterTests { public string Name; public HarryPotterTests(string personName) { Name = personName; } [Test] public void Test() { Console.WriteLine(Name); } } 我想要实现的是查看参数化测试夹具的工作原理.我以前没有使用过,所以这是我的第一个刺. 对我来说看起来不错构造方法使用字符串,并在实际测试夹具属性中传入一个字符串.它编译.测试只需将其写入控制台窗口. 该测试失败,并显示以下消息: No suitable constructor was found 我错过了一些明显的东西吗? 无论我在哪里放置一个断点,都没有任何事情被打击,所以它很早就失败了. 解决方法
我有这个问题.这是由构造函数引起的错误,而不是构造函数参数的任何问题.错误信息在我的情况下是误导性的.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |