unit-testing

Unit testing Android apps and specifically related to db's

What is the easiest way to create some kind of test harness for Android apps and to be able to visualize (even on the emulator) what is going into the db? I want to test things like constraints, look at the data, unit test methods, etc. Is there any kind of GUI tool that I can hook up to the emulator to be able to look at the db of a p...

Under what circumstances do Python unittests fail to run?

I have a standalone Django app that I'm working on right now. You can see the code at Github. In one of the edits, I introduced an error that caused the source tree to be deleted. I reset to an earlier revision, and suddenly my unittests stopped working. I've tried bisecting from an earlier revision, but it turned out nothing useful. A...

Django: Test client's context is empty from the shell

I cannot access the context attribute of an HttpResponse object from ipython. But the unit test accesses context. Here is the unit test. The test run passes properly: from django.test import Client, TestCase from django.core import mail class ClientTest(TestCase): def test_get_view(self): data = {'var': u'\xf2'} re...

C# Unit Test Generation

I know it is possible for VS 2008 to generate unit test code to test C# classes, but I cannot find the right sequence of mouse clicks to generate the code. Any help? ...

Is it possible to test the return value of Haskell I/O functions?

Haskell is a pure functional language, which means Haskell functions have no side affects. I/O is implemented using monads that represent chunks of I/O computation. Is it possible to test the return value of Haskell I/O functions? Let's say we have a simple 'hello world' program: main :: IO () main = putStr "Hello world!" Is it poss...

Unit Test Service which has WCF Call (MSUnit + Moq)

Hi there, I am new to Mocking and somewhat familiar with unit testing and finally have decided to bite the bullet on a new project starting up front with a strict TDD approach. However I have one service class and method I need to retrospectively add tests to as it has been promoted from a prototype. I do not know where to start thoug...

Is there a way to write tests for a Interface and then test it against all classes that implement the test?

I've already checked this.. similar question but I am not convinced about the answers... I currently have an interface that is only being implemented by one class, but that is going to change sooner or later. I currently have a test against the interface, and all tests at the beginning start with: IFoo foo = GetConcreteFoo() where Ge...

JUnit Tests - what do i test?

If I have a basic accessor method that returns an ArrayList What exactly would i test for it? I am very inexperienced when it comes to testing. ...

Rails fixtures - defining a table name?

Hi, At the minute all my fixtures have the same name as the table that they are intended for, because of a recent issue with rails it doesn't seem possible to have a fixture beginning with the word 'test' Does anyone know of a way to have a different fixture name and then map it to the correct table? Thanks, Andy ...

How to check if a list is ordered?

I am doing some unit tests and I want to know if there's any way to test if a list is ordered by a property of the objects it contains. Right now I am doing it this way but I don't like it, I want a better way. Can somebody help me please? // (fill the list) List<StudyFeedItem> studyFeeds = Feeds.GetStudyFeeds(2120, DateTime.Today.Ad...

Is there a python hamcrest matcher library for performing XML document matching?

I'm interested in both xpath matching and full document comparisons: assert_that(mydoc, hasTextAtXPath('/foo/bar', 'text')) assert_that(mydoc, matchesStructurally('<some_xml/>')) Does any matcher library exist for this? If not, what is the best place to start with for this type of comparison, so that I can write one of my own? ...

Boost Test Fixture object clearing between tests.

I am having a issue with boost unit testing. Basically I create a fixture which is part of a suite to unit test a Resource cache. My main issue is between tests the Resource cache is becoming empty. So the first test that tests the cache passes then the second one will fail because the data the first test inserted into the cache is no...

Recommendations for unit testing when using Subsonic 3.0 LINQ templates

I have started using Subsonic for a side project and have been loving using it. Simply a blast. I started off wanting to use the LINQ T4 Templates but have since switched to the ActiveRecord templates due to testability. It is very clear how to write unit tests using the active record templates but for the LINQ templates there is no clea...

Is there anyway to unit test javascript functions defined within a function?

Hi all: I would just like to ask whether I would be able to unit test the code inside ExternalFunction within the document.ready? I have tried many things for a while now and still couldn't work out how, and am at my wits end. $(document).ready(function () { var originalExternalFunction = ExternalFunction; ExternalFunction = f...

Rhino Mocks - using AssertWasCalled on Common.Logging ILog.Debug

I'm having trouble using Rhino Mocks to assert that a method was called (and ideally with a particular parameter). The Method is ILog.Debug(FormatMessageHandler) in Common.Logging 2.0 using the new lamba syntax. It works fine using the old way plain ILog.Debug(string). // Sample Code to Test public int TestFuncLambda(ILog log,...

In MSTest, How can I verify exact error message using [ExpectedException(typeof(ApplicationException))]

using MS Test how can verify the exact error message coming from a test method. I know [ExpectedException(typeof(ApplicationException), error msg)] doesn't compare the error message coming from my test method, though in other unit test framework it is doing. One way to solve this problem is to write my uni test using some try catch bloc...

How to set up gcov for code coverage analysis in iPhone SDK?

Hi, I've recently begun unit testing an app I write for the iPhone. I have the basics of creating my own tests down, even if it seems a little sub-optimal. I am, however, having real trouble setting up code coverage analysis using gcov. I followed the instructions here: http://www.cubiclemuses.com/cm/articles/2009/05/14/coverstory-on-t...

How can i reference an embedded data file for data-driven unit tests?

This is my scenario, I want to make a Data-Driven unit test, and for being environment-independent i want to embed the data file in my assembly. How can i reference then in the DataSourceAttribute of the Unit Test?. I'm trying to access an Excel 2003 file using the Microsoft Jet OleDB Provider. The unit test works fine when the file is ...

RhinoMocks - Not specifying all parameters in AssertWasCalled

I am using RhinoMocks. Now I want to assert that some function was called, but I only care about one of the arguments. Can I do a AssertWasCalled where I only specify one argument? In the following example I'd like the ignore what was sent to the second argument of SomeOtherFunction(). I.e. I want to check that SomeOtherFunction was ca...

Unable to examine reponse headers in unit test

I have a unit test for an Http handler. In it I create a HttpResponse object and pass it to one of my Http handler's methods. One of my tests attempts to verify that the response headers have been set correctly: Assert.AreEqual( "gzip", response.Headers["Content-Encoding"]); However, the Headers property throws a PlatformNotSupported...