unit-testing

Why does using UITableViewCell from a unit test cause a Trace/BPT trap?

I have the following minimal test case in a minimal project created following the GHUnit README: #import <GHUnitIOS/GHUnitIOS.h> #import <UIKit/UIKit.h> @interface MyTest : GHTestCase { } @end @implementation MyTest - (BOOL)shouldRunOnMainThread { return YES; } - (void)testFoo { UITableViewCell *cell = [[UITableViewCell al...

unit testing memory leaks

I have an application in which a lot of memory leaks are present. For example if a open a view and close it 10 times my memory consumption rises becauses the views are not completely cleaned up. These are my memory leaks. From a testdriven perspective i would like to write a test proving my leaks and (after I fixed the leak) asserting I ...

Grails Integration testing: problems with get

Hi, I'm trying to write a simple integration test, but having some trouble with Domain Objects. I've read on unit testing but can't figure it out. This is my simple test: User user = User.get(1) controller.params.userid = "1" controller.session.user = user controller.save(); The error message is: groovy.lang.Mis...

How do I skip tests for the "compile" and "install" target only but not the "test" target?

I have a situation where our unit tests take a long time to execute for our business domain project as it sets up a database to a known state then proceeds to execute each step. I understand this can be done with "-Dmaven.test.skip=true" on the command line but wish to configure this within NetBeans for the project only, globally would b...

How to play sound after running unit tests in Visual Studio

When I am developing on my local machine, I want Visual Studio to play a happy sound when I run my unit tests and they pass and a sad sound when one fails and a really sad one when more than one fails. How do I do this? I assume that I need to write a macro, but I can't find any environment events that relate to unit tests. I am using V...

Make VS 2010 unit tests usable with generic constraints?

It seems to me that when there is just a single class in an assembly that has a generic constraint, unit tests in the VS 2010 unit test framework do not work for the complete assembly. Compilation of the unit test assembly leads to an error. This was a known bug in 2008, but it seems to occur - at least for me - still in 2010 RTM bits. ...

Mocking methods with Expression<Func<T,bool>> parameter using Moq

I want to mock this interface using Moq IInterfaceToBeMocked { IEnumerable<Dude> SearchDudeByFilter(Expression<Func<Dude,bool>> filter); } I was thinking of doing something like _mock.Setup(method => method.SearchDudeByFilter( x=> x.DudeId.Equals(10) && X.Ride.Equals("Harley"))). Returns(_dudes);// _dudes is an in-memory list of dud...

Visual Studio 2010 UnitTestAdapter could not be loaded

I have a few dozen VS Solution, each with a a VS Test project in it that I use at work and at home. One day, the tests (in one solution) stopped running, giving me the following error when I run the tests: The test adapter ('Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips....

How to better unit test Looper and Handler code on Android?

I use the android.os.Handler class to perform tasks on the background. When unit testing these, I call Looper.loop() to make the test thread wait for the background task thread to do its thing. Later, I call Looper.myLooper().quit() (also in the test thread), to allow the test thread to quit the loop and resume the testing logic. It's a...

Junit test case: Connection refused case

Hi all, I am writing a Junit(4.x) test to test what happens when the web application is down. When I hit the url in the browser, I get a message saying "Connection refused". I am unsure about what to check for in the assert statements. Do I check the header for this message? -- urlConnection.getResponseMessage() or just say (exp...

Testing workflows in Django

Hi folks, I really love testing and building unit tests, but I find it quite annoying having to build tests for a website's workflow. e.g. Register -> Check email -> Activate account -> Login or Login -> Edit details -> Submit and view profile manual testing = loads of time + tireing even when using app such as Selenium, going t...

How do you test default sort in a grails unit test with mocked domains

Is it possible to test the sort 'propertyName' which is defined in the staticMappingBlock This works during the integration phase but not during the unit phase where my domain has static mapping = { sort 'lastName' } void testDefaultSortOrder(){ def agent1 = new CommissionAgent(firstName: 'fred', lastName: 'b', active:true).s...

What happens between TestMethods in MS Visual Studio Unit Tests

The title says it - What happens between TestMethods in MS Visual Studio Unit Tests? I have a bunch of TestMethods in a TestClass that has a TestInitialize method. The TestInitialize method internally loads a Type via Reflection (eg. Type.GetType("MyContainer, MyContainerAssembly") ). MyContainer is a class that inherits from WindsorCo...

How to get Resharper to allow underscores in method names but only in Tests?

I know that there is a way to do this, but I can't find it again. So, does any one know how to allow Resharper to allow underscores in unit tests? So, for example I want this to be OK In MyClassTest.cs public void MyMethodName_StateUnderTest_ExpectedResult() {} But I want this to flag: In MyClass.cs public void MyPoorly_Nam...

Code coverage in vs 2010

Hey guys, We just switched over to VS2010, and I remember a while back I had setup code coverage for a project I was working on in 2010, and there being a little bit of setup involved. I can't seem to remember the steps in wiring up code coverage with my unit test results. Anyone know the steps? ...

Is there an MS Test Runner that is faster

MS Test is killing me. It is so slow compared to NUnit. I am stuck with it because I need to be able to get Test Results into TFS easy. (Plus it works better with Pex and I am using that too). But I would really like it to go faster. Even just a bit faster would be nice. Has anyone made a test runner for MS Test tests that goes fas...

Unit test a class that has Imported values by MEF

Hi, I have a a class called "ViewFactory" and this class should deliver the right view right now it has only one method (and it will grow) which I want to write a unit test against. the class looks like this... public class ViewFactory { [ImportMany(AllowRecomposition=true)] IEnumerable<ExportFactory<DependencyObject, I...

How do I check if the Create method was called using Expect instead of AssertWasNotCalled in Rhino Mocks?

How do I check if Create was not called without using the Rhino Mocks AssertWasNotCalled method. Here is the test: [Test] public void When_try_to_create_directory_that_already_exits_return_false() { var directoryInfoMock = MockRepository.GenerateMock<IDirectoryInfoWrap>(); directoryInfoMock.Stub(x => x.Exist...

Perl Test::More and setting up test requirements.

With Test::More I often want to have a module that runs tests and has the ability to abort the callers test_plan. I have a series of tests that set up a plugin list for Catalyst::Test. I don't want to have to make my test check to see if they exist; instead, I want my script to abort if those plugins aren't present. I was trying to trac...

ASP.NET MVC - Unit testing, mocking HttpContext without using any mock framework

Since I'm having problem with unit testing RenderPartialViewToString() with Moq framework (http://stackoverflow.com/questions/3621961/asp-net-mvc-unit-testing-renderpartialviewtostring-with-moq-framework), I'm thinking about getting my controller directly, without using Moq for these particular test, however, how do I mocks (or set) the ...