我有一个测试类,下面我发布了测试类的示例测试
namespace AdminPortal.Tests.Controller_Test.Customer { [TestClass] public class BusinessUnitControllerTests { private IBusinessUnitRepository _mockBusinessUnitRepository; private BusinessUnitController _controller; [TestInitialize] public void TestInitialize() { _mockBusinessUnitRepository = MockRepository.GenerateMock<IBusinessUnitRepository>(); _controller = new BusinessUnitController(_mockBusinessUnitRepository); } [TestCleanup] public void TestCleanup() { _mockBusinessUnitRepository = null; _controller.Dispose(); _controller = null; } #region Index Action Tests [TestMethod] public void Index_Action_Calls_GetAllBusinessUnit() { _mockBusinessUnitRepository.Stub(x => x.GetAllBusinessUnit()); _controller.Index(); _mockBusinessUnitRepository.AssertWasCalled(x=>x.GetAllBusinessUnit()); } } }
当我运行项目时,我得到以下屏幕
我检查了引用,测试项目有对主项目的引用。知道为什么测试没有运行或说它们没有结论吗?
这是一个 Resharper 问题。在 Resharper options->Tools->MSTEST 中,我取消选中 Use Legacy Runner,现在它可以工作了。