本文介绍了使用NUnit进行单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用NUnit框架进行单元测试。 我的问题是在NUnit中我收到错误MolopolyGame.Testing._Card.TestConstructor: 没有提供任何参数 我正在测试的方法返回一个数组中的随机项。 我有一个方法需要测试
I am using the NUnit framework for unit testing. My question is that in NUnit I am getting the error "MolopolyGame.Testing._Card.TestConstructor: No arguments were provided" The method which i am testing returns a random item in an array. I have a method which i need to test
public string GetCommunityCard() { //generate random community card int card; Random randomCommunityCard = new Random(); card = randomCommunityCard.Next(communityChestCardArray.Length); return communityChestCardArray[card]; }这是我到目前为止为该方法编写的测试
and this is the test that I have written so far for the method
namespace MolopolyGame.Testing { [TestFixture] public class _Card { [Test] public void TestConstructor(string retArray) { Card Card = new Card(); string myCard = Card.GetCommunityCard(); Assert.AreEqual(myCard, retArray); } } }我不太确定我做错了什么? 谢谢
I am not too sure what I am doing wrong? Thank you
推荐答案return communityChestCardArray [card] .ToString()需要在实际方法中添加。 return communityChestCardArray[card].ToString() needs to be added in the actual method.
更多推荐
使用NUnit进行单元测试
发布评论