unit-testing

Write Unit tests into an assembly or in a separate assembly?

When writing unit tests, do you place your tests inside the assembly you wish to test or in a separate test assembly? I have written an application with the tests in classes in a separate assembly for ease of deloyment as I can just exclude the assembly. Does anyone write there tests within the assembly you wish to test and if so what is...

Code Coverage and Unit Testing of Python Code

I have already visited Preferred Python unit-testing framework. I am not just looking at Python Unit Testing Framework, but also code coverage with respect to unit tests. So far I have only come across coverage.py. Is there any better option? An interesting option for me is to integrate cpython, unit testing of Python code and code cove...

How do I create flexible unit tests?

We are currently using unit tests to test our project. We have the majority of functionality covered but I think our tests are too brittle. I was wondering if there are any specific things we can be doing to make the unit tests more flexible so they don't break for the wrong reasons. A couple answers have mentioned being careful of ...

Does TThread work differently in a Delphi 2006 console application?

We have a pretty mature COM dll, which we test using DUnit. One of our recent tests creates a few threads, and tests the object from those threads. This test works fine when running the test using the gui front-end, but hangs when running as a console application. Here's a quick pseudo view of what we have in the test SetupTest; fThread...

Visual Studio 2008 Test View Panel Not Showing All Tests

I have a set of 6 MSTest test assemblies. When I bring up the Test View window and group by Project all of my projects show up save one. I cannot seem to make Visual Studio understand that this project is a unit test assembly. Resharper's Unit Test Runner has no problem identifying this sixth assembly. So the assembly is fine from that ...

running single rails unit/functional test

As title. ruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all require 'test_helper' to require File.dirname(__FILE__) + '/../test_helper'. For some reason most of those test templates have such issue, so I rather to see if there is a hack I could get around it. ...

Beginners introduction to unit testing in Visual Studio 2008

I'm a self-taught developer and my experience is all in small applications that I've developed. I'm currently working on an application that I've made public, and I've realized that I need to start doing good unit testing to catch regressions and generally make sure everything works. I've read up on a previous question. I would like t...

What is red/green testing?

I believe I already know the answer, but I am not 100% sure, so just a quick question: What does Red/Green Testing actually mean? I understand it as "Write your tests first, so that they all fail (= all red), then write your code and watch how each test turns green, and when all are green, you're fine". I heard this in Scott's MVC Talk...

team system unit testing and configuration

In vs team system 2008 unit test, how can i load an application configuration file in the test itself? i have an app.config in the test project, referenced System.Configuration but when running the test, it doesn't see the app.config ...

How can I get PHPUnit MockObjects to return differernt values based on a parameter?

I've got a PHPUnit mock object that returns "return value" no matter what its arguments: // From inside a test... $mock = $this->getMock('myObject', 'methodToMock'); $mock->expects($this->any)) ->method('methodToMock') ->will($this->returnValue('return value')); What I want to be able to do is return a different value based ...

Longest running unit tests?

How can we find the junit tests in our suite that take the longest amount of time to run? The default output of the junitreport ant task is helpful, but our suite has thousands of tests organized into many smaller suites, so it gets tedious, and the worst offenders are always changing. We use luntbuild but ideally it would be something...

Does Application.ExecutablePath return different values depending on the test runner?

I'm trying to see if there's a way to get a consistent unit test result across multiple test runners. The current situation is that we have a test assembly where 4 of the tests pass if you run them in NUnit GUI, but fail if you run them using TestDriven.NET or the ReSharper test runner. In the cases where these tests are failing (a Sys...

phpunit avoid constructor arguments for mock

What is the way to avoid phpunit having to call the constructor for a mock object? Otherwise I would need a mock object as constructor argument, another one for that etc. The api seems to be like this: getMock($className, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, ...

Can I use jmock to replace an implementation returned by a factory?

I have a factory that returns an interface FormatService: public class FormatServiceFactory { public FormatService getService() { ... } } Is it possible to mock out this factory so that it will always return a stub implementation of FormatService - FormatServiceStub in our unit tests? ...

which unit-test framework for PHP: simpletest, phpunit or ?

I'm a big fan of simpletest because it's what I know. It has excellent support for mocking and web-testing. But I'm always scared of stagnating so any compelling arguments to switch would be appreciated. ...

Measuring Testability of C# code

Having come across a link on stack overflow, I have found the writings of Miško Hevery very engaging reading. So good that I am seeing a new approach to what I previously thought I was doing quite well. He talks mainly about Dependency Injection, Automated Unit Testing and Good Design. A number of the good practices he advocates are t...

parasoft C++ unit test question

I work on a project that was just told we had to incorporate Parasoft C++ unit testing tool into any code changes going forward. The problem I face is that we have methods with very small changes and now it seems we are forced to unit test the whole method. Many of these methods are hundreds or thousands of lines of code. I know for cert...

ASP.NET - Separation of concerns

Imagine the following scenario - we have Page1 which contains controls Control A and Control B. Say Control A has a button, and on the click of this button we want Control B to react. But we want to do this in an abstract fashion, i.e. we can't have Control B knowing anything about Control A, and vice versa. That way we can develop the...

How do I write unit tests in PHP?

I've read everywhere about how great they are, but for some reason I can't seem to figure out how exactly I'm supposed to test something. Could someone perhaps post a piece of example code and how they would test it? If it's not too much trouble :) ...

Looking for VB.NET open source projects to learn from

I'm looking for some small, vb.net open source projects that make good use of unit testing. Similar to this question, but for VB.NET. "I would like to improve my unit-testing skills by reading, examining real-world code. Could you recommend any open source projects where the source is extensively tested with unit tests?" Thanks! UPDA...