unit-testing

The Value of Unit Testing

Here are some typical answers(ranked in ascending order of corniness) I get from managers/bosses whenever I bring up the importance of having unit tests and code coverage as an integral part of the development cycle "That is the job of QA, just focus on features and development" "The application is not mission critical, if there are ...

Migrating / Upgrading NUnit to Team system

We are working on a C# windows application that is being upgraded from .Net 1.1 to 3.5. The application uses NUnit for automated testing and we are in turn changing this to Team System 2008. It seems to me that NUnit uses similar attributes and code for assertion? What is the best way to upgrade / migrate this code and are their any pr...

Publish outside unit test results in Visual Studio 2008

Hi. I got an xml file with test results. I tried to add the results to Visual Studio 2008. I did almost everything right except getting the project name which i can't extract from the .xml file to the .trx file The question is what is the correct format of the .trx file so it will show me the project name. ...

Switching Between Using NUnit and MSTest for Unit Testing

How can I configure a .NET solution (C#, .NET 2.0) to to allow other developers to make use of the same unit tests for the solution using either NUnit or MSTest? Background: In this project, some developers use VS2005 Team Edition, and others make use of VS2005 Pro, so not all of the developers are able to run MSTest. Given that this...

Would somebody be willing to explain CHESS to a programmer new to Unit Testing?

I've just recently started using unit testing, and I understand some of the main issues unit testing does not cover is concurrency and complex cross-object interactions (which most modern fully OOP lanugages completely eliminate anyhow.) it is my understanding that CHESS resolves the concurrency problem to some degree? could someone giv...

How do I run unit tests stored in my application direcotry as opposed to in the PHP directory?

I've just installed PHPUnit and wrote a quick class which I saved to C:\PHP and it worked fine. If however I move the php file containing the test class to the tests directory of my application, it returns the error Class firstTest could not be found in .. How do I resolve the problem such that it can see the class in the application t...

Mocking Entity Framework Context

I'm using the entity framework to access my database and I want to mock the database context inside my unit tests so that I can test my middle tier classes free of their dependency on real data. I know that I'm not the first to ask about this (Mocking an Entity Framework Model), but after some googling I have an instinct that it might be...

How do I unit test when ActiveRecord has been turned off?

I have turned ActiveRecord off in my Rails app in the environment config: Rails::Initializer.run do |config| config.frameworks -= [:active_record] end I have models that do not extend ActiveRecord::Base and I want to unit test these models. When I run the tests I get the uninitialized constant ActiveRecord::Base error. How can I te...

Visual Studio 2008 unit tests and nunit

When you right click on a method in a code file in Visual Studio 2008 you get this which creates the unit test skeleton for that method. Is there a way (by means of a template change or some nifty hack) by which I can change this to create unit tests based on Nunit rather than Visual Studio unit testing tools? Something like this… ...

Unit Testing TSQL

Is there anybody out there writing unit tests for their TSQL stored procedures, triggers, functions ... etc. I've recently started making database and restores and installs part of our automated Cruise Control build process. Now I'm thinking about taking it to the next level where we do the install, then run through a list of stored pr...

List all Tests Found by Nosetest

I use nosetests to run my unittests and it works well. I want to get a list of all the tests nostests finds without actually running them. Is there a way to do that? ...

Unit testing code which gets current time

What is the best way to write unit test for code which gets current time? For example some object might be created only at business days, other objects take into account current time when checking permissions to execute some actions, etc. I guess that I should mock up the Date.today and and Time.now. Is this right approach? Update: Bot...

How To Handle Co-Worker Opposed to Unit Testing

On our Scrum team there are a couple of members who crank stuff out to the page without unit testing, then complain when changes are made elsewhere in the code that break their stuff. The refrain is always "It used to work, what did you do?" We are early in moving to Agile, and CI is one of the next things on the agenda. Until then, how...

Help me get started with unit testing in Visual Studio 2008

After spending some hours reading about Unit Testing and test driven development here on StackOverflow and on other sites posts pointed me to, I know two things: I want to use it I don't know where to start There are lots of good posts here about details, best practices etc, but what I am looking for is a beginners tutorial/introduct...

Unit testing and mocking small, value-like classes in C++

Hi, I am trying to set up some unit tests for an existing c++ project. Here's the setup: I have chosen Google Mock, which includes Google Test. I have added another project (called Tests) to the Visual Studio Solution. The units to test are in another project called Main. The plan is to add each cpp file that I want to test to the Tes...

Testing private functions in javascript

I'm using the module pattern in Javascript to separate my public interface from the private implementation. To simplify what I'm doing, my code generates a chart. The chart consists of multiple parts (axises, labels, plot, legend, etc.) My code looks like: var Graph = function() { var private_data; function draw_legend() { ... } f...

Is Test::Unit still relevant in rails?

I am learning Rails the age old way. By reading Agile Web Development with Rails (3rd Edition) as a starting point. I am currently in the chapter that teaches Testing. I am also aware of other BDD Testing framework such as RSPec. So I was wondering if frameworks such as RSpec, Cucumber, Shoulda replace the need for knowing/using Test::Un...

Downloading webpage image from SSL + WatiN

I've been thinking about this and can't seem to find a way to do this: I've got some code running on WatiN 2.0 which connects to a site via an SSL tunnel, and after performing certain tasks (which there're no other feasible ways to automate without relying on a browser) should be able to download an image from the very same SSL connectio...

Unit testing my controller method results in an empty ViewName?

Hi folks, I'm doing some simple MS unit tests on my standard, nothing special controller. When i check the ViewName proprty, from the returned ViewResult object, it's "" (empty). I'm under the impression that the ViewName is implied by the name of the View (as suggested by this MS article on ASP.NET MVC controller testing). BTW, whe...

How to I test an HTTP-Post with Moq in ASP.NET?

Hi folks, i've got the following Action Method I'm trying to moq test. Notice the AcceptVerbs? I need to make sure i'm testing that. here's the method. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Include = "Subject, Content")]Post post, HttpPostedFileBase imageFileName) { ... } here's the moq code i have... ...