unit-testing

Testing in Visual Studio Succeeds Individually, Fails in a Set

When I run my tests in Visual Studio individually, they all pass without a problem. However, when I run all of them at once some pass and some fail. I tried putting in a pause of 1 second in between each test method with no success. Any ideas? Thanks in advance for your help... ...

Unit testing a Hibernate driven application?

This may be a naive question, but I am new to both the junit and hibernate frameworks and I was wondering what the best way to go about unit testing an application that is largely calls to hibernate, or if it is even necessary to do so? What is the best practice here? EDIT: Spring seems to be the big suggestion here. Unfortunately thi...

What is the best way to unit test an asynchronous method?

I can't seem to find a .NET answer to this problem, which I would have thought would be fairly common. What is the best pattern for unit testing an asynchronous method? Obviously I need to call the method and then see if the callback fires, but is there a better way than simply sleeping for a bit and then checking for a flag that is set...

Linq2Sql Testing

I have test database and a production database. When developing I of course work against that test database then when deploying I have to semi-manually update the production database (by running a batch-sql-script). This usually works fine but there's a chance for mistakes where the deployed database isn't the same as the test database. ...

Visual Studio Unit Testing of Windows Forms

We're working on a project here in Visual Studio 2008. We're using the built-in testing suite provided with it (the Microsoft.VisualStudio.TestTools.UnitTesting namespace). It turns out, that much to our chagrin, a great deal of complexity (and therefore errors) have wound up coded into our UI layer. While our unit tests do a decent j...

Caching result of setUp() using Python unittest

I currently have a unittest.TestCase that looks like.. class test_appletrailer(unittest.TestCase): def setup(self): self.all_trailers = Trailers(res = "720", verbose = True) def test_has_trailers(self): self.failUnless(len(self.all_trailers) > 1) # ..more tests.. This works fine, but the Trailers() call t...

Creating nunit tests without exporting them with the api

I'm new to unit testing using nunit (and Java development in general). When creating unit tests for private methods on classes, it looks as though the test file must be in the same package as the class being tested. What is the typical way of avoiding exporting the APIs of the unit tests? Can I make the classes/test methods package-pr...

Relevance of Red Green Light Testing

I am starting, and loving, TDD, however wondering about the red green light concept. I do understand in theory the importance of ensuring you can fail a test before passing it. In practice, however, I am finding it somewhat a futile practice. I feel I can't properly write a failing or passing test without implementing the code I am inte...

How do I retrospectively create unit tests for a .NET application?

I am new to unit testing but am beginning to think I need it. I have an ASP.NET web forms application that is being extended in unforeseen directions meaning that certain bits of code are being adapted for multiple uses. I need to try and ensure that when changing these units I don't break their original intended use. So how do I best go...

Should I unit test methods which are inherited from super class?

I'm currently writing an implementation of a JDBC driver (yes, you read that correctly) in a TDD manner and while I have only finished class stubs at this point and only some minor functionality, it just occured to me that since Statement is a superclass for PreparedStatement which is a superclass for CallableStatement, what should I do ...

Debug.WriteLine() happening twice when running tests

I have an odd problem in VS2008 running unit tests. When I run the unit test using either Resharper or TestDriven, in either normal or Debug mode, the Debug.WriteLine("foo") lines are being carried out twice: ie. in the Output window of VS I can see each line written twice. If I step through the test, however, each line seems to be carr...

Do you separate your unit tests from your integration tests?

I was just wondering if anyone else just sees integration tests as just a special unit test. I have, however, heard from other programmers that it is a good idea to separate your unit tests and integration test. I was wondering if someone could explain why this is a good idea. What sorts of advantages would there be to treating integr...

Easy way to mock a WCF service?

I've got an app which is using a WCF service. Now I'd like to add unit tests to the app. For some cases I need to mock the WCF service, since getting the desired behaviour from the service sometimes is tough (e.g. service throws special exceptions). I could add yet another interface to the wcf client, but this seems a bit silly, since ...

Best practice for debug Asserts during Unit testing

Does heavy use of unit tests discourage the use of debug asserts? It seems like a debug assert firing in the code under test implies the unit test shouldn't exist or the debug assert shouldn't exist. "There can be only one" seems like a reasonable principle. Is this the common practice? Or do you disable your debug asserts when unit te...

Hudson, C++ and UnitTest++

Has anyone used Hudson as a Continuous-Integration server for a C++ project using UnitTest++ as a testing library? How exactly did you set it up? I know there have been several questions on Continuous Integration before, but I hope this one has a narrower scope. EDIT: I'll clarify a bit on what I'm looking for. I already have the buil...

Testing Line-of-Business (LOB) .NET Applications?

Hello all, I was wondering if anyone here has experience in unit testing LOB applications (typically CRUD). I have dabbled in the built-in unit testing tools in Visual Studio, but I have found it difficult to run tests that hit a database. Since the data changes, and combined with the fact that I have little idea what I'm doing, it se...

TDD - How much do you test?

I'm working on a new project and I'm using the repository pattern, I have my repository that pulls the data from the database and a "service" class which uses the repository and does all the business logic. something similar to the following; public class UserRepository : IUserRepository { public IQueryable<User> GetUsers() { ...

JUnit's @Ignore

I wonder if it is a good practice to use JUnit's @Ignore. And how people are using it? I came up with the following use case: Let's say I am developing a class and writing a JUnit test for it, which doesn't pass, because I'm not quite done with the class. Is it a good practice to mark it with @Ignore? I'm a little concerned that we m...

Warning signs for untestable code

Code that is untestable really annoys me. The following things make oo-code untestable: global states, e.g., the Singleton Design Pattern static methods that do some fancy work e.g database access deep inheritance tree work in constructor e.g. control statements classes that violate the Single Responsibility Principle Are there more ...

Testing tools for Django Project

Can anyone please suggest me some good testing tools for a django project? I need to test the different use case scenarios, unit testing, as well as load testing for my project. Is there any good standard testing suite available?? Any other suggestion(s) for the testing process is greatly appreciated. I use Django, postgresql on Ubuntu s...