unit-testing

making a call to add_postgis_srs before GeoDjango model tables get created

Here is my model definition for a model in a GeoDjango app (with a PostGIS 8.4 database) meant to represent a Chicago neighborhood boundary: class Neighborhoods(models.Model): objectid = models.IntegerField() pri_neigh_field = models.CharField(max_length=3) pri_neigh = models.CharField(max_length=50) sec_neigh_field = mo...

Spring Test Framework and annotation-based autowiring Problem

Hi I would like to use two different implementations for a DAO with Spring's testframework. src.main.java .businessobjects \-User.java .dao \-IUserDAO.java .daojpa \-UserDAO.java .daohibernate \-UserDAO.java The spring testcase in: src.test.java.base: package base; import org.junit.runner.RunWith; import org.springfr...

How to instantiate PrivateType of inner private class

I was trying to setup a unit test for a private inner class, but had very little success: namespace Stats.Model { public class DailyStat { private class DailyStatKey // The one to test { private DateTime date; public DateTime Date { get { return date; } set { date = value.Date; } } ...

How to delete all database data with NHibernate?

Is it possible to delete all data in the database using NHibernate. I want to do that before starting each my unittests. Currently I drop my database and create it again but this is not acceptable solution for me. ========================================================== ok, here are the results. I am testing this on one database (Post...

Test DataAccess class build on WCF service

Hey, I put my NHibernate data access class in WCF service to can consume it by Silverlight project, but I have error and want to test my queries. It is possible to test this queries in service class using NUnit ? Earlier I test normally this class but how do it when it is in service class ?? It's my WCF service class: using System; us...

Unit Testing / Eclipse / Command Line

I have project with the following layout (Python 2.4.3) root +--- src +--- xyz +--- __init__.py +--- C1.py +--- C2.py +--- test +--- xyz +--- __init__.py +--- CXMock.py +--- C1Test.py +--- C2Test.py So i'm writing a un...

How to debug Python code that is partially covered by passing unit tests but produces wrong results when being reused?

I have a Python class and its methods are partially covered by unit tests like this: class MyClass: def __init__(self): self.instancevar1 = None # some methods change this value self.instancevar2 = None # some methods change this value ... def method1(self, input_data): ... <self.instance...

Is there a way to set the value of wsgi.input when testing?

When using wsgiref.util.setup_testing_defaults() to set up a WSGI environ is it possible to set the wsgi.input value so that one can test HTTP POST requests? Investigating the wsgi.input value created by setup_testing_defaults() shows that it's a wsgi.validate.InputWrapper object with read, readline, readlines, input, close, and __iter_...

Running JS functions on Selenium RC .Net

I have a index.html file which includes scripts.js in scripts.js: function Add(arg1, arg2) { if(typeof(arg1) == 'string') arg1 = parseInt(arg1); if(typeof(arg2) == 'string') arg2 = parseInt(arg2); return arg1 + arg2; } in my C# code: [Test] public void Tescik() { Assert.AreEqual(sel.GetEval(@"this.browserbot.getUserWindow...

How can you implement test driven development with legacy code?

The situation: millions of lines of code, more than one hundred developers and frequent defects. We want to avoid repeating defects and we want to improve code design (who doesn't?). Test Driven Development (first unit test, then code) sounds ideal: write a test case for each function. But, with so much code written, how can TDD be imp...

Unit testing messages

I have a web page that shows different messages according to different conditions. I want to unit test this so I configured my project to use MVVM and I'm testing my ViewModel. My ViewModel now format different messages. How can I test this? I don't want to reproduce all strings, it seems dirty... Now I'm doing this: void test() { ...

OCMock for iPhone (iOS4, XCode 3.2.3)

I have the last version of OCMock (1.55) and XCode 3.2.3. I have created a test bundle target in my project. What is the best way to use OCMock in my tests? When I add OCMock.framework to the test bundle, this build error appears: "_OBJC_CLASS_$_OCMockObject", referenced from: objc-class-ref-to-OCMockObject in NotificationTests.o ...

Is there any reason in Junit not to create your objects at the declaration?

Is there any reason to put object creation inside of setUp() rather than at an instance variable declaration? I've seen it done this way in books, but the effect is the same and I'm not sure if it was done for a best practice reason, because an earlier version of Junit did not instantiate the object for each test (see here), or if it's ...

Is it better to specify all the parameters of a given in one line, or each parameter on a seperate line?

Is it better to specify all the parameters of a given in one line, or each parameter on a seperate line? i.e. which is better? seperate And for each parameter Scenario: some random scenario Given a menu with a menu width of 19 And quit text of "quit" And Fruit options of |Text| |some text| When ... Then ... or ...

asp.net mvc integration test

Hi Im doing TDD for an asp.net mvc project, I need to be able to do end to end testing fie sending a request to the controller action all the way to the repository. I have tried using http://blog.stevensanderson.com/2009/06/11/integration-testing-your-aspnet-mvc-application/ but unfortunately I cant get this to run and Im running out o...

Remove environmental variable programmatically

I need to write a unit test for some C++ code that checks for the presence of an environmental variable. I'm using MSVS 2008 and gtest as my framework. I add the environmental variable using putenv, I check the environmental variable using getevn, but I can't figure out how to remove it so that no other test will see it. I realize this i...

How can iPhone Nibs be Unit Tested using Logical Tests?

Unit Testing View Controllers seems to be very important part of iPhone Development (see this Article). This, however, requires initializing the Controllers from a Nib, which I found impossible to do properly in a logical test. Loading Resources from a Bundle (see this Question) in a logical test works fine. Even loading Nibs is possibl...

How does "Typemock Isolator" mock static methods?

As some of you will know, it is generally not possible to mock a static method in .net. By mocking, I mean to replace a method in a class with another method with the same signature, usually for testing purposes. The two main methods used for mocking a method are to declare it virtual or define it in an interface. Neither of these two...

Unit tests for std::map

Does anyone know where I can find unit tests that will test std::map? The reason I ask is because I have written a class that acts as a replacment for std::map and has virtually all the same functionality, so unit tests for std::map will be suitable for my class, too. Of course, I can write my own, but if someone has already written ex...

HTML code in Rails YAML-fixtures

HI, i have an "Article" model, that has HTML as it's content. I have created some test data with YAML fixtures and faced following problem: As i say "rake db:fixtures:load", following error appears: ArgumentError: syntax error on line 22, col 0: <li>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ...