Given the following controller class:
public class ProjectController : Controller
{
public ActionResult List()
{
return View(new List<string>());
}
}
How can I get a reference to the model object in the following unit test?
public class ProjectControllerTests
{
private readonly ProjectController controller;
...
On the SO blog and podcast Joel and Jeff have been discussing the, often ignored, times when unit testing a particular feature simply isn't worth the effort. Those times when unit testing a simple feature is so complicated, unpredictable, or impractical that the cost of the test doesn't reflect the value of the feature. In Joel's case,...
I have a web part that uses PortalSiteMapProvider to query the Sharepoint navigation hierarchy, but unit tests written for that code fail, because the code is being run outside the Sharepoint context and thus no site map providers are available.
I've identified two alternate ways of solving this dilemma:
Because Sharepoint is basicall...
Can anyone point me to some information on .NET assemblies spanning multiple files?
I've found this remark on MSDN (here):
Although it's technically possible to create assemblies that span
multiple files, you're not likely to use this technology in most
situations.
I'm asking because I have the business logic and the unit test...
Hi, I'm trying to learn how to use JMock and I'm a bit confused about what you use the .proxy() method for. I know its invoked on your Mock class but I don't understand what its puprose is.
I haven't had any luck finding a good description about how it works on google.
Any help is much appreciated.
...
Definitions
In ASP.NET MVC, there are two ways to do model binding in an action. Let's call these the "Bind arguments way" and the "UpdateModel way." Both of them do almost exactly the same thing, and they do it in almost exactly the same way:
public ActionResult UpdateWithBindArguments(Foo model)
{
Repository.Update(mo...
Do you believe that Unit Testing (and test driven development) must be done under any set of circumstances or should there be some exceptions.
I've been working on the type of projects lately where I can't see how Unit Testing would be useful or improve design, quality of code, etc. One type of project is PDF reports generator which tak...
My test fixtures often have "setup" member functions that cannot be called during construction of the fixture since they have parameters that will change based on the tests that will be run. They are written to avoid code duplication.
Are these functions creating an invalid test because they rely on complex, non-production means of bein...
I'd like to unit test my Android application but I found that test driven development in Android is far from trivial at the moment.
Any tips, tricks, war stories for building light weight and preferably fast running tests?
...
Having just read the first four chapters of Refactoring: Improving the Design of Existing Code, I embarked on my first refactoring and almost immediately came to a roadblock. It stems from the requirement that before you begin refactoring, you should put unit tests around the legacy code. That allows you to be sure your refactoring di...
I have legacy asp.net 1.1 website. It has a very poor VB layered achitecture. Debugging takes about 10 minutes to run the credit card processing tests.
I'd like to add some unit testing capabilities to the solution to check my changes.
I was thinking about using mbunit with galleo. Will mbunit and galleo work with my .net 1.1 code...
I am using shanselmann's MvcMockHelper class to mock up some HttpContext stuff using Moq but the issue I am having is being able to assign something to my mocked session object in my MVC controller and then being able to read that same value in my unit test for verification purposes.
My question is how do you assign a storage collection...
Hi All,
I am using Ruby's Test::unit to compare the result of generated html with the expected result. (not using rails). I am not concerned with whitespace differences but these nearly always crop up during tests. Is there any testing mechanism to compare html while ignoring meaningless whitespace. I can see there's similar question f...
When I run my unit tests in my project I am seeing a result "Not executed" for every one. I have restarted my computer so I doubt this is some kind of hung process issue.
Google has revealed nothing. Does anyone have any ideas?
...
I'm new to F# and I intend to create new F# project, and unit test it with F# in Visual Studio 2008, but the Visual Studio 2008 Unit Test Wizard don't have a F# test project option (just have C, C# and VB options).
Is it possible to unit test F#?
Is it possible to unit test F# with a F# test project?
Is it possible to unit test F# with...
Most of the stackoverflow posts about ASP.NET MVC unit testing talk about a specific issue or specific thing to test such as testing HtmlHelpers. Others on the subject of best practices have surprisingly few answers. Available videos I have watched are completely useless in my opinion - and mind blowingly long (by the time you've watched...
Hello,
If a developer implements code for some module and wants to get it reviewed. What should be the order :
*First unit test the module after designing test cases for the module, debugging and fixing the bugs and then give the modified code for peer code review
(Pros- Code to be reviewed is 'clean' to a good extent. Reduces some a...
I am just getting involved in Moq and unit testing, so forgive me if this seems obvious (a quick search through SO didn't show me anything like this).
I have an interface with the following proposed member:
void AddFeed(Feed feed);
That I would like to write a unit test for this functionality. The test class has a Moq Repository decl...
My role at my company is the sole developer, and my experience is limited (I got the job mostly because I'm probably the only person who will do it for the money they're willing to pay - but I digress) compared to the averge developer but more extensive than the average recent grad.
As such I'm looking for some good books to fill in the...
What type of applications did you use this TDD, unit testing approaching (web app, compiler, rails, etc?).
What language was your application written in?
Did you use a preexisting unit testing frameworking like junit or nunit or did you you rollo your own.
Did you use automatically code generate your test cases or was most of the work t...