unit-testing

"Zero Iteration" - end to end acceptance test in simple contact-form feature

I was reading "Growing Object-Oriented Software, Guided by Tests" lately. Authors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing. Ok, so I've start writing a v...

Speeding up Django Testing

Im looking to learn more about your testing flows with Django. Background information http://docs.djangoproject.com/en/dev/topics/testing/ Im encountering difficulties when using test driven development. The test runner of Django constantly creates all db models in a test db when starting. For our current projects (between 40 and 240 m...

Rails3: Cloning already-validated object prevents clone being invalidated -- is this strange or normal?

In Rails (3.0) test code, I've cloned an object so I can clobber it for validation testing without changing the original. If I have called assert(original.valid?) before cloning, then the clone passes the validates_presence_of test even after I have set member_id value to nil. The two tests below illustrate this. In test one, the clone...

How much faster is NUnit compared to MSTest

Roy Osherove, author of The Art Of Unit Testing, has commented on a blog that of the many things NUnit supposedly does better, it being much faster is one of them. My question is how much faster though, if at all? Are we talking an order of magnitude? 10%? 50%? I'm asking this because for the moment I can't compare the two. I am tryin...

Bulk data set up for Unit Test cases

I have developed an application with Spring MVC that deals with bulk data insert/update. For ex: There are some use cases that insert a record with 100-125 attributes. For bulk data insert, I'm hard coding the values to be inserted in my Unit test class. I have Transfer Object to carry the data, so i'm populating these TOs in my Unit ...

How to capture stdout/stderr with googletest?

Is it possible to capture the stdout and stderr when using the googletest framework? For example, I would like to call a function that writes errors to the console (stderr). Now, when calling the function in the tests, I want to assert that no output appears there. Or, maybe I want to test the error behaviour and want to assert that a ...

Our project contains 2600 class files - where and how should we start writing junit tests?

Our project contains 2600 class files and we have decided to start using automated tests. We know we have should have started this 2599 class files ago, but how and where should large projects start to write tests? Pick a random class and just go? What's important to know? Are there any good tools to use? ...

Asserting return type of MVC Controller Action

How can you assert that an expected type is returned when it is wrapped up in a System.RuntimeType? As part of a larger unit test to verify that an action has the correct parameters and action filters assigned I'm asserting against a populated instance of MethodInfo. When I assert against "action.ReturnParameter" it fails as it's say...

Replacing a C function from a common .o file for the scope of a single test executable

So, I've got a library call init_foo(), and a function bar() that calls it. These live in library.o along with some other useful stuff that both need. I want to write some code, bar_init_failure.t.c, to test what happens when init_foo() fails, without actually setting up the failure. In Perl, the bulk of our codebase, I'd launch Test::R...

JUnit Testing for Automated Testing Scripts?

I recently joined this organisation that I am currently working at that has asked me to re factor, extend and maintain an existing Automated Testing Framework written in java, which uses a keyword driven framework and RFT. I have been a developer all my life. By habit I write unit tests to test for behavior before writing source code. Th...

Is this an example of when you'd explicitly unit test a private method?

It seems as though the general consensus of the testing community is to not test private methods. Instead, you should test private methods by testing the public methods that invoke them. However, something just doesn't feel right to me. Let's take this method for example: /** * Returns the base name of the output generator class. If th...

PHPUnit Test How Many Times A Function Is Called

I'm working on a test in phpunit and I'm running into an issue. I have a public function on my class that I am trying to test. Depending on the parameters passed in to the method, a protected function also in my test class will be called one or two times. I currently have a test in place to check that the return data is correct, but I...

Mock objects in C++

What are Mock objects? Can you please explain the concept? How to make use of Mock objects in C++? Any source examples will be highly helpful. ...

PHPUnit error with AddDirectoryToFilter

Hello Everyone, I am again trying to work on a TDD (Test Driven Design) way. So I installed my PHPUnit again to work with my ZendFramework application. After running my testSuite I get this following error message: (...) test: [exec] PHP Notice: Please no longer include "PHPUnit/Framework.php". in /usr/share/php/PHPUnit/Framewor...

Where to store the unit test classes?

So far I've always stored my unit test on my HDD, as I'm the only one in the company to actually care about them, but I'm thinking of cheking them in the repository in order to use them in my CI server, and look into code coverage, so I'm wondering... where do you find the corresponding projects to be better stored in a SVN repository? a...

Unit testing a method with random behaviour

I am writing unit test cases for a game I am working on. When the game starts, the player is positioned randomly, and I have two problems with that: Since the player is positioned randomly, I cannot be sure that a test case that passes once will pass again. For example, it could pass most of the time, but fail if the player happens to ...

Rails3: Find method not working with fixtures in test environment

The Rails Guide says, "Fixtures can also transform themselves into the form of the original class. Thus, you can get at the methods only available to that class," and gives the example, # using the find method, we grab the "real" david as a User david = users(:david).find My fixtures are working ok, but when I try memb = member...

Example of application covered with tests

Hi guys, is there sample/open_source application for download that is covered with tests(integration, unit, ...) and could be example how testing should be done? We want to learn our junior programmers how tests should be written(ok ok, and we(seniors) want to learn, too :)) Thanx ...

Use unit tests in unusual architecture when porting from VS6 to VS2008?

Hello, we have one main application, which executes up to 5 different exes. These exes run independently and communicate with each other via UDP. Changing this architecture is not planned at the moment. We want to migrate this whole thing from VS6 to VS2008. I'm thinking about adding unit tests to make sure that after migration everyth...

How to revert the database back to the initial state using dbUnit?

I am new to automated testing and dbUnit. So I would appreciate your advice. I am going to create a test suite, that will run the following way: create an in-memory H2 database run DDL scripts to create tables run dbUnit to insert initial data (let's call it STATE0) that will be used by all tests. run tests Till there it looks nice ...