unit-testing

Why can't I delete a file in %ProgramFiles% from a Unit Test via Resharper's Test Runner Unit Test?

I am trying to write a test which, in it's fixtures Setup, it backs up a file and deletes the original, runs the test without the original present, then in the teardown, restores the original from the backup. The file is located in my %ProgramFiles% folder. I get an UnauthorizedAccessException on the fileInfo.Delete() statement. I hav...

How do I unit-test inheriting objects?

When you use composition, then you can mock the other objects from which your class-under-test depends, but when you use inheritance, you can't mock the base class. (Or can you?) I generally try to prefer composition over inheritance, but sometimes inheritance really seems like the best tool for the job - well, at least until it comes t...

What is the unit testing strategy for method call forwarding?

I have the following scenario: public class CarManager { .. public long AddCar(Car car) { try { string username = _authorizationManager.GetUsername(); ... long id = _carAccessor.AddCar(username, car.Id, car.Name, ....); if(id == 0) { throw new Exception("Car w...

Do you have unit testing in your projects?

I know unit testing is important - everbody knows that. But in most projects that I see there is almost no unit testing (except open source frameworks), but a lot of human acceptance testing. What's your experience? ...

Testing Abstract Class Concrete Methods

How would design and organize tests for the concrete methods of an abstract class? Specifically in .NET. ...

Do you test private method?

I have read the post about how to test private (http://stackoverflow.com/questions/34571/whats-the-best-way-of-unit-testing-private-methods) method because I usually do not test them, I always thought it's more fast to only test public method that will be called from the external of the object. Do you test private method? or Should I al...

Automatically Generating SQL Schema from XML

We are attempting to use a SQL Server 2003 database for our test records and want a quick way to take NUnit and NAnt output and produce SQL schema and data. Is there a simple way to generate SQL Schema using the XSD file describing these XML documents? ...

Unit Testing File Modifications

A common task in programs I've been working on lately is modifying a text file in some way. (Hey, I'm on Linux. Everything's a file. And I do large-scale system admin.) But the file the code modifies may not exist on my desktop box. And I probably don't want to modify it if it IS on my desktop. I've read about unit testing in Dive Into...

Unit Testing Guidelines

Does anyone know of where to find unit testing guidelines and recommendations? I'd like to have something which addresses the following types of topics (for example): Should tests be in the same project as application logic? Should I have test classes to mirror my logic classes or should I have only as many test classes as I feel I ne...

Making code internal but available for unit testing from other projects

We put all of our unit tests in their own projects. We find that we have to make certain classes public instead of internal just for the unit tests. Is there anyway to avoid having to do this. What are the memory implication by making classes public instead of sealed? ...

How does one add a custom build step to an automake-based project in KDevelop?

I recently started work on a personal coding project using C++ and KDevelop. Although I started out by just hacking around, I figure it'll be better in the long run if I set up a proper unit test suite before going too much further. I've created a seperate test-runner executable as a sub project, and the tests I've added to it appear t...

Any suggestions for testing extjs code in a browser, preferably with selenium?

We've been using selenium with great success to handle high-level website testing (in addition to extensive python doctests at a module level). However now we're using extjs for a lot of pages and its proving difficult to incorporate Selenium tests for the complex components like grids. Has anyone had success writing automated tests f...

What is your single favorite book or online resource for getting started with unit testing?

I am looking for a book or online resource that gives a good overview of the subject, and is also practical for implementing unit testing. The book should be useful for users of different programming languages. ...

Unit testing MFC UI applications?

How do you unit test a large MFC UI application? We have a few large MFC applications that have been in development for many years, we use some standard automated QA tools to run basic scripts to check fundamentals, file open etc. These are run by the QA group post the daily build. But we would like to introduce procedures such that in...

How can I unit test responses from the webapp WSGI application in Google App Engine?

I'd like to unit test responses from the Google App Engine webapp.WSGIApplication, for example request the url '/' and test that the responses status code is 200, using GAEUnit. How can I do this? I'd like to use the webapp framework and GAEUnit, which runs within the App Engine sandbox (unfortunately WebTest does not work within the s...

Is it feasible to introduce Test Driven Development (TDD) in a mature project?

Say we have realized a value of TDD too late. Project is already matured, good deal of customers started using it. Say automated testing used are mostly functional/system testing and there is a good deal of automated GUI testing. Say we have new feature requests, and new bug reports (!). So good deal of development still goes on. Note...

Is there a Java unit-test framework that auto-tests getters and setters?

There is a well-known debate in Java (and other communities, I'm sure) whether or not trivial getter/setter methods should be tested. Usually, this is with respect to code coverage. Let's agree that this is an open debate, and not try to answer it here. There have been several blog posts on using Java reflection to auto-test such metho...

How to simulate memory allocation errors

My C application uses 3rd libraries, which do their own memory management. In order to be robust, my application has code to deal with failures of library functions due to lack of free memory. I would like to test this code, and for this, I need to simulate failures due to lack of memory. What tool/s are recommended for this? My enviro...

Testing all classes which implement an interface in Java

Is there anything out there (for Java specifically) that allow you to automatically test the behavior of an interface? As an example, let's say I have a bunch of tests for the Comparable interface, that should apply to anything that implements Comparable. What I'd like is to be able to include "ComparableTests" automatically in the test ...

What not to test when it comes to Unit Testing?

In which parts of a project writing unit tests is nearly or really impossible? Data access? ftp? If there is an answer to this question then %100 coverage is a myth, isn't it? ...