unit-testing

How much unit testing is a good thing?

(No "related questions" seem to nail this, so here goes.) I work on production code. Arguing for anything that isn't visible to the user is hard to do, sometimes. If sales can't see it, it's an external cost to them, and they'll argue against it unless there's a great reason not to. How much unit testing is a good thing? If you test...

Mocha + Cucumber to mock the Net response

The following is the app/models/websites.rb class Masterpiece < ActiveRecord::Base validates_presence_of :title, :link validates_uri_existence_of :link, :allow_redirect => false end The second validation is from the plugin Validates Existence of URI plugin The following is the features/support/mocha.rb file require 'mocha' W...

What is different about the CMake command configure_file on Windows?

On linux I am using a command such as: configure_file(dot_alpha_16.bmp test/dot_samples/dot_alpha_16.bmp COPYONLY) to copy some unit test files to the build directory. On windows the files aren't getting copied. Is there a specific reason why this happens? ...

How can I run individual tests with Test::Class::Load?

After having accumulated enough tests that running them all takes some real time, I looked at the Test::Class::Load doc to find a tip for running individual test classes. It provides a manner to do this, but I must be missing something, because I can't make it work. Here's what I have: My test directory: drewfus:~/sandbox$ ls t/ lib/...

[.Net] Is it possible to change the way unit tests are invoked?

My guess is that the current semantics of unit testing involve actually calling the method, i.e., if I have a method MyTest() then that's what gets called. My question is this: is it possible to somehow change the pipeline of the way tests are executed (preferably without recompiling the test runner) so that, say, instead of calling the ...

VisualStudio.TestTools.WebTesting.TestDescriptionAttribute Syntax

What is the syntax to use the [TestDescriptionAttribute][1] of a test to populate the Description column in the Test Results window? Context: Visual Studio 2008 Team System I've read the documentation, but am not able to find a concrete example. Based, loosely, on Ngu's suggestion, I've tried: using GlobalSim; using Microsoft.Visual...

Console and Debugger not working while Unit Testing iPhone in XCode

Hello folks, I am building a logic test suite using Xcode 3.1.4. I am able so far to build the test target and see the results inside de *.m test files as compiler errors (if they fail). The problem is that I can't see any information in the Debugger Console and I can't debug since the debugger does not work either. 1.How can I do to...

Testing a class that uses asynchronous execution

I have a bunch of unit tests that work on a class which executes some tasks asynchronously. Currently I set up the class, then execute the function in question. I then go into a blocking wait until the execution is completed, then test the data I need to. Is there a better way that I can do this? So far my tests look similar to this: ...

How to mockup a base controller in asp.net mvc?

Hi I have a base controller that I made so I can pass data to the master page view easily. However this base controller gets a service layer passed into it and everything time I run my unit tests this service layer kills it since it tries to access some database stuff. private ServiceLayer service; public ApplicationControll...

How to Mock up AuthorizeAttribute in asp.net mvc?

Hi I have my own custom Authorize Attribute and I am trying to check my controller methods to see if they have the correct roles in place. Now my custom authorize tag has database code in it. The ways I am mocking it up don't seem to work since the reflection stuff I found seems to to just pass no arguments so my default constructor i...

Support for loose collection validation in a Java unit testing framework

Any Java unit testing framework that supports writing unit testing code like this: Collection<AType> myCollection = objectUnderTest.doSomething(); assertCollectionContainsAtleast(myCollection, "a Expected value"); Meaning what I would like is some sort of iteration support with some sort of matcher attached. ...

How do i test an "if(somecondition) return;" statement?

Using NUnit 2.5 in VS 2008, i'm not sure how to test that a function simply return;s when some condition is set. Is there an Assert method that serves my purpose, or is this not testable? ...

What are the good frameworks for unit-testing and mock objects in Perl?

What frameworks and tools would you recommend for unit-testing and mock objects in Perl? I have an existing Perl application, that mainly does database access, reading and writing files. The application is basically a batch job type of application, it reads in bunch of stuff from files and database and writes a bunch of new files and so...

Unit testing using NDBUnit framework

Am writing unit tests for an app that has matured a lot with time..We are using NDBUnit as the test cases become independent of each other..while we started the development of this app the DB schema was pretty manageable and hence dragging and dropping the tables on VS designer to create an XSD was never an issue. Well, with my current D...

How to create a state-based test for a method that calls other methods within the same class?

I have the following code (which I've dumbed down for the question): public void HandleModeInit(int appMode){ switch(appMode){ Case 1: DoThis(); Case 2: DoThat(); Case 3: //no mode 3 Case 4: DoSomethingElse(); ...

uninitialized constant Test::Unit::TestResult::TestResultFailureSupport

I get the error in subj when I'm trying to run specs or generators in a fresh rails project. This happens when I add shoulda to the mix. I added the following in the config/environment.rb: config.gem 'rspec', :version => '1.2.6', :lib => false config.gem 'rspec-rails', :version => '1.2.6', :lib => false config.gem "thoughtbot-shoulda"...

The new syntax for Rhino Mocks

Hi, I am struggling a bit to understand how the new AAA syntax works in Rhino Mocks. Most of my tests look like this: [Test] public void Test() { //Setup ISth sth= mocks.DynamicMock<ISth>(); //Expectations Expect.Call(sth.A()).Return("sth"); mocks.ReplayAll(); //Execution ...

How to write unit tests in spec form?

I have difficulty in many situations to come up with a good unit test names for classes and methods. Typically, I try to follow the form: public class TestContext { [Fact] public void WhenThis_DoThat() { } } Some put words Given, When, and Then on the parts to be explicit. I like it because it seems to make the unit ...

MVC moq unit test the object before RedirecToAction()

I want to test the data inside the "item" object before it redirect to another action. public ActionResult WebPageEdit(WebPage item, FormCollection form) { if (ModelState.IsValid) { item.Description = Utils.CrossSiteScriptingAttackCheck(item.Description); item.Content = Utils.CrossSiteS...

What is wrong with Stubs for unit testing?

I just watched this funny YouTube Video about unit testing (it's Hitler with fake subtitles chewing out his team for not doing good unit tests--skip it if you're humor impaired) where stubs get roundly criticized. But I don't understand what wrong with stubs. I haven't started using a mocking framework and I haven't started feeling the...