unit-testing

Need help with error using MvcContrib.TestHelper's ShouldMapTo() generic extension method

I'm trying to unit test my routes using the MvcContrib.TestHelper ShouldMapTo<TController>() extension method, but my tests fail with the following error message: failed: Method MvcContrib.TestHelper.RouteTestingExtensions.ShouldMapTo: type argument 'ReviewController' violates the constraint of type parameter 'TController'. But Review...

iPhone: How to fix a legacy iPhone app which has really bad memory management? unittesting?

Hi, I recently inherited an iPhone app. The original developer did not understand memory management and well the app works in simlulator but not in on old iPhone (lots of crashses). Do you have any thoughts on the process by which I can save the app? Can I utilize or create any unittest to find memory leaks and make the process 'scien...

Having trouble getting NUnit's Assert.Throws to work properly

I could have sworn that I've used NUnit's Assert.Throws to determine whether or not a particular exception gets thrown from a method, but my memory has failed me before. I read this post here on SO, but it didn't answer my question, as I know the correct syntax, and I don't want to do anything with the exception that gets returned (I do...

Integration testing: Start a blocking server during `unittest.setUp` before testing it?

I'm writing a service using Thrift and need to apply some tests to ensure that it operates/responds as expected. To accomplish this, the most robust approach seems to be to use the unittest module. I'd like to start the service in "test" mode (starts on a specific "test" port, uses "test" data, etc) from directly within the unit test's...

how to test or describe endless possibilities?

Example class in pseudocode: class SumCalculator method calculate(int1, int2) returns int What is a good way to test this? In other words how should I describe the behavior I need? test1: canDetermineSumOfTwoIntegers or test2: returnsSumOfTwoIntegers or test3: knowsFivePlusThreeIsEight Test1 and Test2 seem vague and it woul...

Unit testing framework for .NET, Comparison!

I have used a bit of MS VS2008 integrated Unit Testing framework for writing unit test, but not that extensive, any suggestions which framework will work best for web based applications developed using ASP.NET. ...

How do I get Visual Studio to place the unit tests where I want them?

In both VSTS 2008 and VS 2010 RC1 when I create a Unit Test (mstest), I am not asked where I would like the project to be placed. It will always turn up at the Solution level. I would like to place the test project inside the folder of the class(es) that are being tested. I have tried unloading the unit test project and adding it to t...

TDD test data loading methods

I am a TDD newb and I would like to figure out how to test the following code. I am trying to write my tests first, but I am having trouble for creating a test that touches my DataAccessor. I can't figure out how to fake it. I've done the extend the shipment class and override the Load() method; to continue testing the object. I feel...

How to run only the latest/a given test using Rspec?

Let's say I have a big spec file with 20 tests because I'm testing a large model and I had no other way of doing it : describe Blah it "should do X" do ... end it "should do Y" do ... end ... it "should do Z" do ... end end Running a single file is faster than running the whole test suite, but it's still pretty long. Is there ...

Where to ask practical unit-testing questions?

Before i can understand unit testing, i have to see real world examples. Every book, blog, article, or answer i've seen gives hypothetical examples that don't apply to the/my real world. i really don't want to flood StackOverflow with hundreds of questions all titled "How do i unit-test this?" There must be another place i can go to as...

Android Unit Testing - Resolution & Verification Problems

I just switched the way my Android project is being built and non of my unit tests work any more...I get errors like WARN/dalvikvm(575): VFY: unable to resolve static field X in ..... WARN/dalvikvm(575): VFY: unable to find class referenced in signature These errors only come from my Unit Tests, where classes defined in it can't even...

moqing static method call to c# library class

This seems like an easy enough issue but I can't seem to find the keywords to effect my searches. I'm trying to unit test by mocking out all objects within this method call. I am able to do so to all of my own creations except for this one: public void MyFunc(MyVarClass myVar) { Image picture; ... picture = Image.FromStrea...

Testing a patch to the Rails mysql adapter

I wrote a little monkeypatch to the Rails MySQLAdapter and want to package it up to use it in my other projects. I am trying to write some tests for it but I am still new to testing and I am not sure how to test this. Can someone help get me started? Here is the code I want to test: unless RAILS_ENV == 'production' module ActiveR...

What's the state of PHP unit testing frameworks in 2010?

As far as I can see, PHPUnit is the only serious product in the field at the moment. It is widely used, is integrated into Continuous Integration suites like phpUnderControl, and well regarded. The thing is, I don't really like working with PHPUnit. I find it hard to set up (PEAR is the only officially supported installation method, and...

Unit testing classes - is throwing errors out of the question?

I am getting my head around PHPUnit, and trying to build a test case for an existing class. The class is a static configuration class, getting, setting and listing configuration options that will be available in the application. The class is very strictly built. If I try to set a configuration setting with an incompatible value, or a c...

Testing routes with host constraints via assert_routing in Rails

I have a route which I'm using constraints to check the host and then a route which is essentially the same but without the host restriction (these are really namespaces but to make things simple this example will do): match "/(:page_key)" => "namespace_one/pages#show", :constraints => proc {|env| env['SERVER_NAME'] == 'test.mysite.loc...

not using partial mocking? do they also mean in web-app?

Im learning Mockito and in chapter 16 they say you should not use partial mocking in new system. I disagree, for example in one of my actions i use partial mocking for static framework methods, sql calls, etc. I extracted the stuff into methods and then mock it in tests. Most of those methods are specific to this action and wont be call...

How to set a variable within a mock object

Is there any way to set a class level variable within a mock object? I have the mock object set similar to this: $stub = $this->getMock('SokmeClass', array('method')); $stub->expects($this->once()) ->method('method') ->with($this->equalTo($arg1)); Win the real class there is a variable that needs to be set for it to...

NUnit's TestCaseAttribute equivalent in Visual Studio 2008 unit test framework

Is there an NUnit's TestCaseAttribute equivalent in Visual Studio 2008 unit test framework? You know, something like this: [TestCase(1, 1, 1)] [TestCase(2, 2, 2)] [TestCase(3, 3, 3)] public void Test1(int a, int b, int c) { // do stuff depending on the TestCase } Thanks in advance ...

Unit-tests for a working codebase with limited time: How?

I have a few medium-sized Rails apps that I work on routinely, and only one of them has any unit tests at all. But I have seen the light and I want to change all that, except... I don't have the time to go in and starting writing tests class by class or something like that. How do you start writing unit tests on an existing -- and worki...