unit-testing

NUnit TestCase with Generics

Is there any way to pass generic types using a TestCase to a test in NUnit? This is what I would like to do but the syntax is not correct... [Test] [TestCase<IMyInterface, MyConcreteClass>] public void MyMethod_GenericCall_MakesGenericCall<TInterface, TConcreteClass>() { // Arrange // Act var response = MyClassUnderTest.My...

Testing dialog in Android's ActivityUnitTestCase

I'm trying to test an Activity in android which will show a ProgressDialog and everything works fine in the App, however when I try to use ActivityUnitTestCase and the test causes the Activity to show the dialog it fails with this error: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an appli...

Semi-automated testing of external libraries and error-prone interactions

Recently I have been trying to use unit tests in my code, and I like the idea in principle. However, the parts of my code that I am most eager to test are those error-prone areas which unit tests alone don't handle very well; for example: Network code Filesystem interactions Database interactions Communication with hardware (e.g. speci...

Factory Girl: Automatically assigning parent objects

I'm just getting into Factory Girl and I am running into a difficulty that I'm sure should be much easier. I just couldn't twist the documentation into a working example. Assume I have the following models: class League < ActiveRecord::Base has_many :teams end class Team < ActiveRecord::Base belongs_to :league has_many :play...

MSTest Equivalent for NUnit's Parameterized Tests?

NUnit supports a feature where you can specify a set of data inputs for a unit test to be run multiple times. [RowTest] [Row(1001,1,2,3)] [Row(1,1001,2,3)] [Row(1,2,1001,3)] public void SumTests(int x, int y, int z, int expected) { ... } What's the best way to accomplish this same type of thing using MSTest? I can't find a similar...

Unit testing an ActionFilter - correctly setting up the ActionExecutingContext

In a custom ActionFilter, I want check the attributes on the controller action that will be executed. Running through a small test application, the following works when launching the app in the asp.net development server- public class CustomActionFilterAttribute : ActionFilterAttribute { public override void OnActionExecuting(Action...

Running unit tests under Chess

When trying to run my unit test under Chess, it get the following error: Hosting rules specify that the test type 'Unit Test' cannot run in the host adapter 'Chess'. To run this test in 'Chess', change the hosting rules. To use the default test host for tests that cannot be run in the specified host adapter, change the te...

Google app engine Unit Test servlets

Hi, I am wondering if it is possible to test Google App Engine Servlets using Cactus or HTTPUnit? If possible, is there a reference/guide on this? Thanks! ...

Rails Single Table Inheritance with HABTM Fixture in unit testing returning NoMethodError: undefined method `singularize'

Imagine a model structure as follows: models/cross_sell_promotion.rb class CrossSellPromotion < Promotion has_and_belongs_to_many :afflicted_products, :join_table => :promotion_afflicted_products, :foreign_key => 'promotion_id', :association_foreign_key => 'product_id', :class_name => 'Product' has_and_belongs_to_...

How do interfaces making unit testing and mocking easier?

Hi, It is often said that interfaces making mocking and unit testing an easier process. How do interfaces help with this? Thanks ...

junit4 functions

how to create generic functions that could be called from each java test? In my function startappli I have : public class startappli{ public void testMain (String[] args) { String[] logInfos = new String[3]; logInfos[0] = (String) args[0]; logInfos[1] = (String) args[1]; } @BeforeClass public static void setupOnce() {...

How to reuse test code from open source project

I'm writing a unit test for a custom subclass of org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T> and I need a stub implementation of org.springframework.http.HttpInputMessage. Looking through the Spring unit tests in the SVN repository, I found the class MockHttpInputMessage, which does exactly what I want. Now...

Mocking View with RhinoMocks

We are using MVP (Supervising Controller) for ASP.NET WebForms with 3.5 SP1. What is the preferred way to check the value of a view property that only has the a set operation with RhinoMocks? Here is what we have so far: var service = MockRepository.GenerateStub<IFooService>(); // stub some data for the method used in OnLoad in the pr...

Is Scrum possible without test driven development?

I have now witnessed two companies move to agile development with scrum. In both cases the standard of coding was good enough when each part of the application was only being work on by one or two developers with the developers spending a reasonable amount of time working on one part of the application before moving to the next task. ...

How do I run Javascript tests in Windmill when using test_windmill for Django?

Hi, I'm using the Windmill test system and have it running using test_windmill for Django which works fine for the Python tests. I'd like this to run a suite of Javascript tests also whilst the Django test server is running. I've used the run_js_tests call from the Windmill shell which works fine but I can't find a way to have this run ...

testing mouse events in wpf

for example, here's some code from an implementation of an attached behavior for a double click command: private static void fe_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount != 2) return; ... } assuming you have a thin client with the bulk of the logic in a testable architecture, is there ...

Any teams out there using TypeMock? Is it worth the hefty price tag?

Hi, I hope this question is not 'controversial' - I'm just basically asking - has anyone here purchased TypeMock and been happy (or unhappy) with the results? We are a small dev shop of only 12 developers including the 2 dev managers. We've been using NMock so far but there are limitations. I have done research and started playing with...

Unit testing methods that call methods with dependencies to the data access layer

I work on codebase that doesn't have any unit tests in place and I'm trying to get add some unit testing to it. The code is VB.NET but isn't very object oriented. We're using NUnit for unit testing. A lot of the classes have shared/static methods. I'm trying to unit test a method that calls other methods that use the data access layer. ...

AbstractTransactionalJUnit4SpringContextTests: can't get the dao to find inserted data

I'm trying to set up integration tests using the AbstractTransactionalJUnit4SpringContextTests base class. My goal is really simple: insert some data into the database using the simpleJdbcTemplate, read it back out using a DAO, and roll everything back. JPA->Hibernate is the persistence layer. For my tests, I've created a version of t...

How do you unit test your ASP.Net MVC JsonResult actions?

I'm still figuring out a few of the finer points around unit testing my ASP.Net MVC2 application using NUnit. On the whole, testing my ActionResults, models, respositories and the like is straight-forward, but I've not had to test Ajax methods before and I'd like some guidance on how I should best go about it. Thanks in advance. ...