unit-testing

Rails Testing: Fixtures, Factories, and Magic numbers

I've got an application that needs quite a bit of data (1000s of records) to do appropriate testing. The only way I've found to get a decent set of testable, sensible data is to use a subset of my production DB. I've converted this to YAML fixtures in the normal `test/fixtures' location. This works, but now I have a bunch of seemingly...

Humble dialog vs MVC

Why should I choose to use one instead of the other and in which cases? I mainly focus on desktop applications and personally speaking I do find the humble dialog box more easy and natural to use. ...

GWT Unit Testing TDD and Tooling

hi there I m just starting using gwt and so far so good, however after reading some sample code I wonder is it necesary to have a high level of test coverage? (I can see that most code is declarative and then add some attributes I can see the sense in checking so me particular attributes are there but not all) Also i would be intereste...

How to mock classes instantiated as local variables

I'm writing tests for a business method that invokes some DAO classes to perform operations over a database. This method, firstly retrieves a JDBC connection from a DataSource object, The same connection is passed to all DAO instances, so I can use it to control the transaction. So, if everything works properly, I must invoke commit() o...

VSTestHost.exe has stopped working - can't run unit tests

The Microsoft unit testing framework has suddenly gone on strike. When I try to run tests in VS2008, I get a dialog with the message "VSTestHost.exe has stopped working". I have Visual Studio Team System 2008 (version 9.0.30729.1 SP) running on Vista with all updates applied. The "Problem reports and solutions" suggests that I "Upgra...

What are you using to unit test your C++ code?

I'm looking into some possible options for unit testing C++ classes. So, short and to the point, what are you using? ...

Why should unit tests test only one thing?

What Makes a Good Unit Test? says that a test should test only one thing. What is the benefit from that? Wouldn't it be better to write a bit bigger tests that test bigger block of code? Investigating a test failure is anyway hard and I don't see help to it from smaller tests. Edit: The word unit is not that important. Let's say I con...

Unit testing large data sets?

What's the best way to unit test large data sets? Some legacy code that I'm maintaining has structures of a hundred members or more; other parts of the code that we're working on create or analyze data sets of hundreds of samples. The best approach I've found so far is to serialize the structures or data sets from disk, perform the ope...

Parsing C++ to generate unit test stubs

I've recently been trying to create units tests for some legacy code. I've been taking the approach of using the linker to show me which functions cause link errors, greping the source to find the definition and creating a stub from that. Is there an easier way? Is there some kind of C++ parser that can give me class definitions, in ...

Could you recommend any open source projects where the source is extensively tested with unit tests?

Programming is learned by writing programs. But code reading is said to be another good way of learning. 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? I'm interested in code written in C++. Thanks...

How to unit test if my object is really serializable?

I am using C# 2.0 with Nunit Test. I have some object that needs to be serialized. These objects are quite complex (inheritance at different levels and contains a lot of objects, events and delegates). How can I create a Unit Test to be sure that my object is safely serializable? ...

Is there hard evidence of the ROI of unit testing?

Is there hard evidence of the ROI of unit testing? Unit testing sounds great to me, but I'm not sure I should spend any time really learning it unless I can convince others that is has significant value. I have to convince the other programmers and, more importantly, the bean-counters in management, that all the extra time spent learni...

Daylight savings time change affecting the outcome of saving and loading an icalendar file ?

I have some unit tests that started failing today after a switch in daylight savings time. We're using the iCalendar python module to load and save ics files. The following script is a simplified version of our test. The script works fine in 'summer' and fails in 'winter', as of this morning. The failure can be reproduced by setting ...

Mocking HttpContext doesn't work

I am trying to mock out HttpContext so that I can unit test my controller's Request.IsAuthenicated call. I am using the code that I found at Scott Hanselman's blog to simulate HttpContext using rhino.mocks. so i have this unit test piece: PostsController postsController = new PostsController(postDL); mocks.SetFakeControllerContext(post...

Approaches to creating the View for "Humble Dialogs"

I have a bunch of questions to post regarding the issue of separating the view from logic when creating a GUI. The following is a minimal example of what I would do for a simple dialog that has a label and a button using the "Humble Dialog" approach. Pressing the button should show some text on the label. I have used C++ an Qt that I am ...

What is a "Unit"?

In the context of unit testing, what is a "unit"? ...

How do you unit test different class access levels?

I admit - I'm a complete novice when it comes to unit testing. I can grasp the concepts easily enough (test one thing, break-fix-test-repeat, etc.), but I'm having a bit of a problem getting my mind around this one... I've been tasked with rewriting a large section of our application, and I've got the class structure down pretty well. W...

Is mutation testing useful in practice?

It exists the technology of mutation testing. It checks, if the tests are running even if you change the code. If not all is OK, if the tests are running they don't cover all eventualities. There is some theoretical work about it, but I'm interested in the question, if it is useful in practice? Do you have any examples of real life appli...

Comparison of c++ unit test frameworks

I know there are already a few questions regarding recomendations for c++ unit test frameworks, but all the answers did not help as they just recomend one of the frameworks but do not provide any information about a (feature) comparison. I think the most interesting frameworks are CppUnit, Boost and the new Google testing framework. Has...

Best practice Unit testing abstract classes?

Hello I was wondering what the best practice is for unit testing abstract classes and classes that extend abstract classes. Should I test the abstract class by extending it and stubbing out the abstract methods and then test all the concrete methods? Then only test the methods I override and the abstract methods in the unit tests for o...