unit-testing

Android Activity Testing Example Has Confusing OnPause Expectations

I'm trying to understand the Activity Testing tutorial on the Android site. One of the tests sets a spinner in the SpinnerActivity example, forces a pause, then resets the spinner, forces a resume, and then verifies that the application properly restored the state. I pasted the relevant code at the bottom of this question for reference...

Unit testing all controllers from a single test

I just created an action filter that I want to apply to nearly all of my controllers (including any new ones that are introduced later on). I figure a really useful unit test would be one that cycles through each controller and verifies that if certain criteria are met, then the action filter will impact the result. Is it wise to creat...

Unit testing large non-member functions

Hey all, I have a function, which I'd like to get under test. However, it's very large and creates a finite state machine. The function looks roughly like: std::auto_ptr<IFiniteStateMachine> CreateFSM() { std::auto_ptr<IFiniteStateMachine> = apFSM( new CFiniteStateMachine() ); std::list<IState*> listStates; listState.pus...

ActiveRecord Rollback does not work in Rails test

Throwing ActiveRecord::Rollback works, but not in tests. I've had this problem before, am now having it again, and for some reason can't find any record of someone else having this problem. I'm this is because tests do a rollback each time a test runs, and most databases don't support nested rolllbacks. However, I can't be the only pe...

How to write unit tests for STI associations Ruby on Rails

What steps should you use when in a need to write unit tests for STI associations. I am completely confused. Please provide some suggestions or links to some tutorials. Thanks in advance ...

Implementing Unit Testing and Acceptance Testing Halfway Through A Project

I am having a lot of headaches maintaining a website right now. Most often things would end up breaking after a couple of updates. This website was started by two developers in our team and then passed on to me. I was wondering if it would be alright to go with unit testing and acceptance testing considering that I'm halfway through the ...

Moq SetupGet errors but setting property on .Object works fine

I'm trying to define a return value for a Mock (model). Can anyone explain to me why the following code fails with a "Invalid setup on a non-overridable member": model.SetupGet(x => x.PostCodeSearch).Returns(It.IsAny<string>); and yet I can do this and it works fine: model.Object.PostCodeSearch = "Any value as long as it's not null ...

How to effectively (not) test service layer

In one of our service classes I have a bunch of methods which just return the DAO result with no processing like public void acceptRequest(User from, User to) { rosterDAO.acceptRequest(from, to); } The unit test for this method looks like this private final RosterDAO rosterDAO = context.mock(RosterDAO.class); ... public void tes...

How to test that objects get updated using a fake repository

Say I have the following business logic: foreach (var item in repository.GetAll()) { if (SomeConditition) { item.Status = Status.Completed; repository.Update(item); } } Now I write the following unit test: public void Test() { var repository = new FakeReposit...

How to check that activity displays dialog during android unit testing

I want to write testcases for my android application using JUnit. And I faced some problems. Is it possible to check that activity displays some dialog at current moment? Here is a small piece of my test application: ... Instrumentation instr = getInstrumentation(); monitor = instr.addMonitor(MainActivity.class.getName(), n...

Stop VS2008 Unit Tests from creating loads of files?

After years of faithful nUnit use, I'm having a fling with the Visual Studio Unit Testing framework thats built into VS2008. Apart from the crushing guilt ; ) ... one of the issues is that 'VSTest' creates a file and a folder every time you run tests, and those files ('Visual Studio Test Results File') and folders really build up over t...

Rails3: How to recreate test fixtures based on development database schema (newbie)

The situation: I used generate scaffold to set up my objects in a new Rails project. Besides doing some migrations, I also directly edited the MySQL tables by adding and renaming columns etc. Now I can't get tests to run because the automatically-generated fixtures do not correspond to the database schema. Perhaps they're based on the or...

How do I unit test protected properties meant to be set only by NHibernate?

I'm using NHibernate to persist this entity: public class Store { public int Id { get; protected set; } public int Name { get; set; } } Note how the Id property has a protected setter. This is to prevent users from changing the Id while still allowing NHibernate to assign it an Id when it saves it to the database. In one of m...

Elegant way of overriding default code in test harness

Let's say I have the following class: class Foo { public: Foo() { Bar(); } private: Bar(bool aSendPacket = true) { if (aSendPacket) { // Send packet... } } }; I am writing a test harness which needs to create a Foo object via the factory pattern (i.e. I am not instan...

Create an in-memory database structure from an Oracle instance

Hello, I have an application where many "unit" tests use a real connection to an Oracle database during their execution. As you can imagine, these tests take too much time to be executed, as they need to initialize some Spring contexts, and communicate to the Oracle instance. In addition to that, we have to manage complex mechanisms, s...

Django load test fixtures with django-nose

How do you load test fixtures using the django-nose test runner? ...

How to execute code after trigger_error(..., E_USER_WARNING) in unit test (PHPUnit)?

I have code like this: class ToBeTested { function simpleMethod($param) { if(0 === $param) { trigger_error("Param is 0!", E_USER_WARNING); return false; } return true; } } and test for this code: class SimpleTest extends PHPUnit_Framework_TestCase { function testSimpleMethod() { $toBeTest...

What is a good tutorial for getting started with iPhone unit testing using OCUnit?

I am trying to get OCUnit to do anything on my project, but I am failing :-( Is there any good tutorial out there to get it work? Everything I find tells something different and they are all pretty complicated ... What I tried is e.g. set up a Unit Testing Target add my Target as dependency add a xxTest.m to my unit target and writ...

Are there any good frameworks for automated testing of AWT GUIs?

Are there any good frameworks for automated testing of AWT GUIs? Integration with JUnit would be a plus. ...

producing a correct and complete xml unit testing report (for Hudson)

I'm extending RUnit (a unit testing suite for R) so that it produces also output that can be read by Hudson. actually I already have something that does this, but it does not handle 'deactivated' tests. to see what I mean, have a look at the r-forge project 'rtest' (it temporarily identifies itself as RUnit, but it further works rather...