unit-testing

What's the difference between using the constructor in VS Testing framework vs. TestInitialize() attribute?

Quick question, I'm using the Visual Studio's testing framework for unit testing. Just wondering what's the difference between using the constructor to do initialization work vs. having a method with [TestInitialize()] attribute? ...

How does the garbage collector work with unit tests?

Recently, I asked (and answered) a question on StackOverflow about why a unit test would work when run by itself and then fail sporadically when run with the whole batch of unit tests. See here: http://stackoverflow.com/questions/3072986/sql-server-and-transactionscope-with-msdtc-sporadically-cant-get-connection Unit tests passing when...

Find JUnit 3 tests that are not included in any suite?

If someone writes a new unit test but they forget to add it to a suite, the continuous build will continue to pass happily even if someone later breaks the test. Is there a way to discover JUnit tests that aren't included in a suite? EDIT I know I could move to JUnit 4 but then the question becomes, how do I find tests that are missing ...

How to go about adding unit tests to an established (autotools) C project

I have a fork of openssh with some new features and want to write some unit tests to make sure they work at build. Grafting Check into openssh's autotools configuration is diffacult (because I don't really understand autotools) Is there an easier to use C unit test framework? One less closely tied to autotools? How about a better way o...

How simple is 'too simple to break'? - explained

In JUnit FAQ you can read that you shouldn't test methods that are too simple to break. While all examples seem logical (getters and setters, delegation etc.), I'm not sure I am able to grasp the "can't break on its own" concept in full. When would you say that the method "can't break on its own"? Anyone care to elaborate? ...

Making One Unit Test Count as Several

Using Visual Studio Test Suite, is there a way to make a single unit test behave and give results as if it were several tests? I would like to have a test for each set of input parameters I will provide. But I'd rather have all the varieties of input be data-driven, rather than having to write a seperate test for each one. This questi...

Automatically run a list of tests in Visual Studio

Does anybody know how to automatically run a particular list of tests in the test list manager? We have two lists: a list of unit tests and a list of integration tests. Preferably we would like it to run the tests in the 'unit test' list automatically before it checks in to team system. We currently have a check-in rule that ensures th...

Cast from IEnumerable to Queryable in select statement?

Hello, I have a database repository with a bunch of access functions. I now want to build a fake repository which provides similar functionality for unittests. Unlike the real repository, this one uses simple lists instead of linqtosql generated model classes. Most fake repository funtions look exactly like the real ones, just with a...

What is the correct terminology & best practice for common fixtures between test classes?

I understand in Junit 4, @Before can be used to setup test fixtures for the test class's multiple test methods. However, in my system, there are common test objects i would like to have available for all tests. What is the most appropriate name for these objects and what is a good best practice way to store them? ...

Unit Testing results that are retrieved by a processed Thread

I have a unit test in which I mock (with moq) an object and let it verify if it executed a method properly. This method is being executed in a Thread that I create in my SUT (System under Test). When I want to do VerifyAll() on the Mock it could happen that the Thread is still running and that it isn't finished yet executing the method -...

Is there a minimal style for unittests in Python?

I'm wondering what techniques people use for simplifying the 'size' of code used for unit testing. For example I was trying to marshal an object of the class and testing the marshal'ed object (but this presumes marshal is working correctly). Consider the class import unittest class Nums(object): def __init__(self, n1_, n2_, n3_): ...

Problem with Mockito - exceptions.verification.WantedButNotInvoked

Hello people. When I put a "VerificationModeFactory.times(2)" in test before, when I run all tests of the class appears this exception: org.mockito.exceptions.verification.WantedButNotInvoked: Wanted but not invoked: serviceService.getServices(); If I run each test separately or remove "VerificationModeFactory.times(2)" all works. It...

How to run django's test database only in memory?

My django unit tests take a long time to run, so I'm looking for ways to speed that up. I'm considering installing an SSD, but I know that has its downsides too. Of course there are things I could do with my code, but I'm looking for a structural fix. Even running a single test is slow since the database needs to be rebuilt / south mi...

How should I split up large unit tests in ruby?

I'm writing some unit tests for one of my rails models. It's a large model and in some cases I have dozens of assertions for many of the methods. I prefer using plain test/unit with rails' activesupport syntax so I have a file like this: require 'test_helper' class ItemTest < ActiveSupport::TestCase test "for_sale? should be true if c...

Tests won't run on newly-generated plugin

I'm using Rails 2.3.8. I created a standard plugin running script/generate plugin machine_tags and I'm trying to run the default sample test that comes with it under vendor/plugins/machine_tags/test/machine_tags_test.rb. I go to the plugin directory and issue a rake test, but all I get is this: (in /home/helder/code/shapado/vendor/plugi...

In the Java version of Google App Engine, how can you eval and execute Java code and unit tests passed in as strings?

I am currently using an online system running in Google App Engine to enable students to practice coding in python. The system is inspired by codingbat by Nick Parlante and the public version of Beanshell running on appengine. I would like to extend our system to support Java. In our current system, the Python doctest feature makes it ...

How do you write and execute Ruby tests in a Ruby interpreter?

I was working with the lotrepls Ruby interpreter, and I want like to write tests in the interpreter that I can then write Ruby code to pass. In Python, I can write doctests and then write code to pass the doctests. For example: >>> b 1 This tests that b=1, and entering b=1 will get this doctest to pass. Is there a similar way to...

Failed to queue test run: Unable to start the agent process(Visual Studio 2010)

Hi, While trying to run all the unit tests in my solution(Visual Studio 2010) I am getting a 'Failed to queue test run xxxx@MACHINENAME 2010-06-23 14:01:36': Unable to start the agent process' error. Does anyone know what causes this particular error to occur and how to resolve it so that I can run my unit tests? Thanks ...

Does anyone know how to select parts of test methods in a test case run in a test suite?

For example, a test case named ExampleTest ExampleTest { testA{}; testB{}; testC(); } I could run all this class with TestSuite.addTestSuite(ExampleTest.class); but, how to select testA and testB run into TestSuite? ...

Wait for an Actor to exit()

How do I wait for a Scala Actor to exit()? I set up two Actors in a unit test, and send a few messages to get them started. They send a few messages back and forth and eventually both call exit(). How do I make my unit test wait for both Actors to finish up before passing? ...