English 中文(简体)
Where do I store MVC/MVP and Service layer unit tests?
原标题:

In MVC/MVP style applications that have Controller/Presenter classes within the Client Application assembly and then a Services layer assembly containing Service classes, where do people recommend storing their unit tests?

For ease of execution it d be nice to have a single Test assembly that references both the Client and Services, and contains tests for both. But is anything about a dual responsibility Test assembly considered bad design?

Where are other people storing their unit test code?

最佳回答

It s pretty important that you keep unit test projects isolated to only one System Under Test (SUT). If required, you can have more than one unit test project that exercises the same SUT, but not the other way around.

The reason for this is that if you have a single unit test project that exercises multiple SUTs, you are artificially coupling those two SUTs together. This means that you will never be able to migrate one of the SUTs without the other.

In the case of a web application, you may find such concerns irrelevant if you don t plan to reuse any of your libraries, but imagine that you are unexpectedly asked to implement a web service based on the same business logic as the web site currently uses. Your service layer sounds like a good candidate for code reuse, so you may want to reuse it without the MVC-based UI.

The problem now is that you can t, because the single unit test project drags along the unwarranted UI project.

Having a one-to-one relationship between SUTs and their unit tests just makes your life a lot easier.

问题回答

I usually create a unit test project per .NET assembly tested.





相关问题
run unit tests and coverage in certain python structure

I have some funny noob problem. I try to run unit tests from commandline: H:PROpyEstimator>python src estpython est_power_estimator.py Traceback (most recent call last): File "src est...

How to unit-test an enterprise symfony project?

I´m working on a huge project at my work. We have about 200 database tables, accordingly a huge number of Models, Actions and so on. How should I begin to write tests for this? My biggest problem ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Unit testing. File structure

I have a C++ legacy codebase with 10-15 applications, all sharing several components. While setting up unittests for both shared components and for applications themselves, I was wondering if there ...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签