unit-testing

Can I test status bar notifications using Android's testing framework?

I have a class that sends a status bar notification in Android. I can't find a way to test whether the notification was sent or not, which makes it very hard to write any kind of useful unit test. Does anyone have a solution for this? ...

Problem creating MembershipUser for custom MembershipProvider

Hello, I created a custom membership provider and am getting the following error trying to create a new "MembershipUser". Could not load type 'MyTestApp.Membership.TestMembershipProvider' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. I am running this from a Unit Test project, so I'm no...

How to parallelize a Data-Driven unit test in Visual Studio 2010?

I know regular ms-test unit tests can be parallelized on a multi-core machine (with caveats of course) by specifying parallelTestCount attribute in the .testresults file in the test solution. Like this, <Execution parallelTestCount="1"> <TestTypeSpecific /> <AgentRule name="Execution Agents"> </AgentRule> </Execution> Mo...

Asserting exceptions in Java, how?

This might be a conceptually stupid question, but it also might not and since I am still a student I think I should I have no problem asking. Imagine you have a method that if given certain conditions it will throw an NumberFormatException. I want to write a Unit Test to see if the exception is being correctly thorwn. How can I achieve ...

In SimpleTest, is there a way to emulate a MockClass::expectOnce()?

Using PHP/SimpleTest, I want to test if a method calls a static method of another class. Can this be done with a mock class? ...

Does ?assertException actually work with gen_fsm:startlink?

I have the following init method in a gen_fsm callback module (my_fsm): init(Args) when length(Args) =:= 2 -> % do work with Args here {ok, my_state, InitialState}. There is no other init-method in the callback module. I want to write a unit test using eunit where I assert that calling gen_fsm with an argument-list that does no...

View returned from mvc action is blank using moq

The topic says it all. I'm guessing this is because of some missing setup related to MVC, but I'm very new to the world of http, asp.net and mvc, so I'm not quite sure what's wrong. public class MyController : Controller { public ActionResult MyAction(MyModel model) { return View(model); } } var controllerMock = new M...

Selenium/PHPUnit tests always run twice, fail on second pass

The problem I am having is that I have setup runners for my Selenium/PHPUnit tests and they are always being run twice, per test, one after the other. And then it will move onto the next test. I found http://www.phpunit.de/ticket/688 that bug seems to be exactly what is happening to me -- so I removed all references to PHPUnit_MAIN_MET...

Pylons: nosetests, specify location of development.ini?

I'm running nosetests on a remote server. On my local server my test.ini and development.ini files are in the same directory. On my remote server, they are not. If I try to run just nosetests on the remote server, I get: IOError: File '/foo/bar/development.ini' not found Is there an option to specify the location of development...

Can you recommend me a way to create a sample portion of a data-base as an xml file to be consumed by Unit Tests?

Hi, Can you recommend me a way or tell me the most common practice to create a sample portion of a data-base as an xml file so that I can use it from my unit tests without worrying about Db state to be persistent? Is there any frame work to overcome such a scenerio including the functionality that after each test I can get back to the ...

How to design a unit test for generating a PDF document?

I'm late to the party with regards to using unit testing... trying to figure best practices and the such. My question is, given a class which is responsible for generating a PDF (or Doc/Html/Xml/etc.), how would I go about testing the final output file is correct? I figure a text based file (xml), I could just see if the strings match,...

Something similar to NUnit TestCaseSource in Visual Studio unit testing

Is there anything similar to NUnit TestCaseSource attribute in Visual Studio unit testing? The closest solution I found was to use a DataSource. But I don't want to store my test case parameters in a data source. ...

Mark unit test as an expected failure in JUnit

How can I mark a test as an expected failure in JUnit 4? In this case I want to continue to run this test until something is patched upstream. Ignoring the test goes a little too far, as then I might forget about it. I may be able to add an @expected annotation and catch the exception thrown by assertThat, but that also seems to lie abo...

How do I test for TempData being set in MVC 2 where there is a redirect?

When trying to test my MVC 2 controllers, I am having a hard time testing the result of TempData when I'm doing a redirect. It works ok if the result of the controller action is a ViewResult, however, in a redirect, it is RedirectToRouteResult. So my test is something like this: var controller = new SubscriptionController(this.dataSto...

Unit testing with django-celery?

I am trying to come up with a testing methodology for our django-celery project. I have read the notes in the documentation, but it didn't give me a good idea of what to actually do. I am not worried about testing the tasks in the actual daemons, just the functionality of my code. Mainly I am wondering: How can we bypass task.delay(...

What are the unit testing frameworks available in java?

What are the technologies out there? (I only know of JUnit) What is the most popular? Can you please explain the pros/cons of each? Thanks Alot!! ...

How do you mock out a static method of a domain object in Grails?

have a Grails domain object that has a custom static function to grab data from the database class Foo { /* member variables, mapping, constraints, etc. */ static findByCustomCriteria(someParameter, List listParameter) { /* code to get stuff from the database... */ /* Return value is a map ...

Loading a fixture before a south migration run

Hi, I've made a mistake of creating my own User model and am trying to recover. I've created a south migration that copies my old user models and creates django.contrib.auth.models.User models. To ensure my current users don't get left in the dark, I created a bunch of unittests to ensure everything gets converted appropriately. So, I...

VS2010 ASP.NET MVC add unit test to existing project

Is it possible to add the unit testing functionality (in Visual Studio 2010 Web Developer Express) for an already existing ASP.NET MVC project? ...

How to script gdb? Example add breakpoints, run, what breakpoint did we hit?

Hi I'm trying to create a little unit test with gdb, for a embedded mcu that is controlled by OpenOCD (that gives me control over my target via a gdb server). So I would like to automate this with some basic scripting of gdb, but it is not really working. I would like to write some kind of script for gdb that more or less does this...