unit-testing

Unit test break/assert lockin up WCF service?

I am trying to write some unit tests (more integration tests actually) to hit a live IIS server hosting my WCF service. Whenever I run a test though, if one of my Assert statements fails on the client side, my WCF service seems to lock up- and I have to do an iisreset to get things back online. For example, I have in a test method 3 ca...

Unit Testing on build

Any better way to do this? I've used the Continuous Testing AddIn from visual studio gallery, but does not work with SolutionFolders.. so I just added a "Post Build Macro" with "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /testcontainer:"$(TargetPath)" Works great, but when there are errors, all I get ...

RSpec vs. Shoulda?

I am new to the unit testing seen; I have only been using unit tests for about 2 months now. When I unit test in Ruby I currently follow the TDD style and use Test::Unit::TestCase. I have also read about RSpec and how it follows the BDD methodology. I also have read about Shoulda which is a in between the two frameworks. My question is, ...

Nunit parameterised TestFixtures with parameters set at runtime?

I'm interested in being able to instantiate multiple testfixtures with constructor arguments passed to it at runtime by a static method or property returning an IEnumerable. In Nunit 2.5 they introduced parameterised tests and test fixtures. These allow you to write a single test and run it with several inputs provided using the TestCas...

How can I add a test method to a group of Django TestCase-derived classes?

Hi all, I have a group of test cases that all should have exactly the same test done, along the lines of "Does method x return the name of an existing file?" I thought that the best way to do it would be a base class deriving from TestCase that they all share, and simply add the test to that class. Unfortunately, the testing framework ...

Problem with testing validations using Shoulda .

Here's my test. class AlertSettingTest < ActiveSupport::TestCase context "For ALL Alert Settings" do setup do @alert = AlertSetting.create({ :alert_type_id=>'1',:name => 'xxx'}) end subject { @alert } should_belong_to :alert_type should_validate_presence_of :name end end Here's my model. class AlertSetting < ActiveR...

How can I visualize external unit testing results in Aptana/Eclipse?

I have JsTestDriver set up to run tests automatically on remote server, which then produces XML format to my "test-reports" folder. I'm looking for some way to visualize the results automatically in Aptana/Eclipse, so that the other coders wouldn't be forced to check the console output to see if the tests failed or not. Ideally, I would...

Pattern for creating a graph of Test objects?

I have to write Unit Tests for a method which requires a complex object Graph. Currently I am writing a Create method for each Test as shown below. 1. private static Entity Create_ObjectGraph_For_Test1() 2. private static Entity Create_ObjectGraph_For_Test2() ...... And So on The create method has about 10 Steps and they might vary by...

Asserting set up and pre-conditions in Unit Tests

Is having more than one assert per test a really bad smell? I usually try to follow the “arrange, act, assert” pattern as well as the single assert per test guideline. I think having clean, small, isolated tests is pure awesomeness. For the most part I manage to do this. However, sometimes I find myself asserting “pre-conditions” right...

Is it possible to mock Activator.GetObject()?

Hi, I am trying to write a unit test for a method that uses a .net remoting object. The remoting object is created by using Activator.GetObject(typeof(myRemotingObjectType), uri); During runtime, the uri is server ip address of the remoting object. Since I want to write a unit test, I don't want to initialize any .Net remoting to slo...

SelectListItemNotFound Exception using MvcContrib.TestHelper.WatiN with SelectList

When I try to use the MvcContrib.TestHelper.WatiN API to conduct UI unit testing that utilizes AJAX to populate select lists, I receive a SelectListItemNotFound Exception. Aside from using a Sleep statement, is there some way of "pausing" until the list is filled? The link, http://pushpontech.blogspot.com/2008/04/ajax-issues-with-watin...

PHP project with excellent OOP design for studying purposes

Hello, I've recently became interested in proper OOP design in web applications. I think I understand most of the principles and design patterns but sometimes I have problem with putting them into practice. I use MVC and I think I am able to design controllers and views in OOP way. The problem I face is with models. I'm particularly obs...

Best ways to develop painlessly in Javascript on a local machine

I'm pretty new to workign with Javascript. In most languages you can run the code quickly locally on your machine. From what I've seen, in JS you generally only use it via the browser, and so I've been uploading my code an viewing its effects in the browser. This has proven very tiresome. Also, if I mak one error, it seems like my...

Unit tests must locate in the same package?

A JUnit book says " protected method ... this is one reason the test classes are located in the same package as the classes they are testing" Can someone share their experience on how to organize the unit tests and integration tests (package/directory wise)? ...

How to execute test suites based on requirement in boost.test library

Hello, I am using Boost.Test library for implementing unit test cases in C++. Suppose I have two suites such as BOOST_AUTO_TEST_SUITE(TestA) BOOST_AUTO_TEST_CASE(CorrectAddition) { BOOST_CHECK_EQUAL(2+2, 4); } BOOST_AUTO_TEST_CASE(WrongAddition) { BOOST_CHECK_EQUAL(2 + 2, 5); } BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE...

Unit testing UI application.

Can a UI application be unit tested? Lets consider a UI application which has a simple login form. What would form part of unit test for this UI application. Should the backend response validation form part of unit test for login form? In my opinion, It should include; appropriate rendering of UI components in the form. enabling/Di...

MVC 2 Validation Attribute Unit Testing Using IoC

I am currently writing some unit tests for an ASP.NET MVC 2 controller and having some issues with the MVC 2.0 validation attributes. The validation attribute in question uses a repository to check that no duplicate names exist in the current data source, and I would like to replace this repository with a fake one during my unit test. I ...

How to raise Onload/OnUnload event from FrameworkElement for unit testing purposes?

As you can see here, I can't use reflection to get the multicast delegates of the private fields behind these FrameworkElement events because they aren't field-like. So how to do it? ...

Do you know some tools can help to create fake data which was used in unit test of asp.net mvc project

I was using aps.net mvc unit test, and want to create fake data instead of using real database connection, but the Linq query code and real database was huge and complicated, create fake data in unit test which can mimic real database was a huge job! Who knows some tools can help me to create fake data and mimic real database? Thanks! ...

Our code sucks and I'm powerless to fix it. Help!

Our code sucks. Actually, let me clarify that. Our old code sucks. It's difficult to debug and is full of abstractions that few people understand or even remember. Just yesterday I spent an hour debugging in an area that I've worked for over a year and found myself thinking, "Wow, this is really painful." It's not anyone's fault - I...