VS2015单元测试项目找不到方法
VS2015 Unit test project is unable to find a method
我收到此错误:
Result StackTrace: at
UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch()
Result Message: Test method
UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch threw
exception: System.MissingMethodException: Method not found:
'System.Web.Mvc.ActionResult
QuoteCenter.Controllers.ECSearchController.QuoteEndCustomerSearch(System.String,
System.String, System.String, System.String)'.
我的测试 class 看起来像这样:
namespace UnitTestProject
{
[TestClass]
public class ControllerTest
{
[TestMethod]
public void TestMethodQuoteEndCustomerSearch()
{
//arrange
ECSearchController myController = new ECSearchController();
//ISSUE WITH THE NEXT LINE
ViewResult result = myController .QuoteEndCustomerSearch("", "", "", "") as ViewResult;
}
}
}
智能感知知道 myController 有一个方法 QuoteEndCustomerSearch。但是当我调试时出现上述错误。
控制器的方法如下所示:
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult QuoteEndCustomerSearch(String quoteId, String CID, String URL, String UserID)
{
//...
return View("QuoteEndCustomerSearch", model);
}
关于我还应该尝试让它工作的任何提示吗?我处于管理员模式并且我已经重新启动了 VS2015。
问题是我现有的项目有 mvc 版本 5,但新的测试项目有更新的版本。现在一切都好。
我在使用Nuget时没有注意到版本不同。
我认为现在是我将所有项目更新到最新版本 MVC 的好时机。
我收到此错误:
Result StackTrace: at UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch() Result Message: Test method UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch threw exception: System.MissingMethodException: Method not found: 'System.Web.Mvc.ActionResult QuoteCenter.Controllers.ECSearchController.QuoteEndCustomerSearch(System.String, System.String, System.String, System.String)'.
我的测试 class 看起来像这样:
namespace UnitTestProject
{
[TestClass]
public class ControllerTest
{
[TestMethod]
public void TestMethodQuoteEndCustomerSearch()
{
//arrange
ECSearchController myController = new ECSearchController();
//ISSUE WITH THE NEXT LINE
ViewResult result = myController .QuoteEndCustomerSearch("", "", "", "") as ViewResult;
}
}
}
智能感知知道 myController 有一个方法 QuoteEndCustomerSearch。但是当我调试时出现上述错误。
控制器的方法如下所示:
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult QuoteEndCustomerSearch(String quoteId, String CID, String URL, String UserID)
{
//...
return View("QuoteEndCustomerSearch", model);
}
关于我还应该尝试让它工作的任何提示吗?我处于管理员模式并且我已经重新启动了 VS2015。
问题是我现有的项目有 mvc 版本 5,但新的测试项目有更新的版本。现在一切都好。 我在使用Nuget时没有注意到版本不同。 我认为现在是我将所有项目更新到最新版本 MVC 的好时机。