unit-testing

How do I solve this error: "Class PHPUnit_Extensions_SeleniumTestCase could not be found"

I am trying to run a SeleniumTestCase with phpunit but I cannot get it to run with the phpunit.bat script. My goal is to use phpunit with Selenium RC in CruiseControl & phpUnderControl. This is what the test looks like: require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class WebTest extends PHPUnit_Extensions_SeleniumTestCase {...

How to test function call order

Considering such code: class ToBeTested { public: void doForEach() { for (vector<Contained>::iterator it = m_contained.begin(); it != m_contained.end(); it++) { doOnce(*it); doTwice(*it); doTwice(*it); } } void doOnce(Contained & c) { // do something } void doTwice(Contained & c) { // do so...

Why don't they teach these things in school?

Over the summer, I was fortunate enough to get into Google Summer of Code. I learned a lot (probably more than I've learned in the sum of all my university coursework). I'm really wondering why they don't teach a few of the things I learned sooner in school though. To name a few: unit testing version control agile development It s...

Testing GUI code: should I use a mocking library?

Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to make my tests readable...

Unittest causing sys.exit()

No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on. IDLE 1.2.2 ==== No Subprocess ==== >>> import unittest >>> >>> class Test(unittest.TestCase): def testA(self): a = 1 self.assertEqual(a,1) >>> unittest.main(...

Auto-generating Unit-Tests for legacy Java-code

What is the best, preferably free/open source tool for auto-generating Java unit-tests? I know, the unit-tests cannot really serve the same purpose as normal TDD Unit-Tests which document and drive the design of the system. However auto-generated unit-tests can be useful if you have a huge legacy codebase and want to know whether the cha...

Using the same test suite on various implementations of a repository interface.

I have been making a little toy web application in C# along the lines of Rob Connery's Asp.net MVC storefront. I find that I have a repository interface, call it IFooRepository, with methods, say IQueryable<Foo> GetFoo(); void PersistFoo(Foo foo); And I have three implementations of this: ISqlFooRepository, IFileFooRepostory, and IMo...

C# - Excluding unit tests from the release version of your project

How do you usually go about separating your codebase and associated unit tests? I know people who create a separate project for unit tests, which I personally find confusing and difficult to maintain. On the other hand, if you mix up code and its tests in a single project, you end up with binaries related to your unit test framework (be ...

Testing StarTeam operations

In a Java application I need to checkout files from Borland Starteam 2006 R2 using Starteam API by various parameters (date, label). Is there any framework that helps to write automatic tests for such functionality? ...

Is object mocking used extensively?

I am curious about how many of you folks incorporate mocking of objects (frameworks like JMock, NMock, RhinoMocks hand in hand with unit testing frameworks) into your daily development process. What are your experiences? You see, I develop on top of a GIS (geographic information systems) platform, in which most of work pertains to some ...

.NET Testing Naming Conventions

What are the best conventions of naming testing-assemblies in .NET (or any other language or platform)? What I'm mainly split between are these options (please provide others!): Company.Website - the project Company.Website.Tests or Company.Website Company.WebsiteTests The problem with the first solution is that it looks like .T...

What is the best process for a new ASP.NET web app from the ground up?

I am re-building our poorly designed web application from scratch, and wanted to get into TDD and basically "do things right" as kind of a learning project. What tools, processes, and resources are recommended to do it "right" from the start? I will be working alone as the architect and developer, with the backup of a business analyst ...

TestDriven.Net doesn't find tests

I have a test project using MbUnit and TestDriven.Net. If I right-click on an individual test method and say "Run Tests" the test runs successfully. Same thing if I click on a file name in the solution explorer. However, if I right click and say run tests on the project or the solution, TestDriven.Net reports "0 Passed, 0 Failed, ...

C++ unit testing framework

I use the Boost Test framework for my C++ code but there are two problems with it that are probably common to all C++ test frameworks: There is no way to create automatic test stubs (by extracting public functions from selected classes for example). You cannot run a single test - you have to run the entire 'suite' of tests (unless you ...

Unit test for randomized data

I ran across this situation this afternoon, so I thought I'd ask what you guys do. We have a randomized password generator for user password resets and while fixing a problem with it, I decided to move the routine into my (slowly growing) test harness. I want to test that passwords generated conform to the rules we've set out, but of c...

How do I unit test an __init__() method of a python class with assertRaises()?

I have a class: class MyClass: def __init__(self, foo): if foo != 1: raise Error("foo is not equal to 1!") and a unit test that is supposed to make sure the incorrect arg passed to the constructor properly raises an error: def testInsufficientArgs(self): foo = 0 self.assertRaises((Error), myClass = MyClass(Error, ...

Using jmockit expectations with matchers and primitive types

I'm using jmockit for unit testing (with TestNG), and I'm having trouble using the Expectations class to mock out a method that takes a primitive type (boolean) as a parameter, using a matcher. Here's some sample code that illustrates the problem. /******************************************************/ import static org.hamcrest.Match...

Do anyone do test cases for pojos?

Is that needed? ...

What is a reasonable code coverage % for unit tests (and why)?

If you were to mandate a minimum percentage code-coverage for unit tests, perhaps even as a requirement for committing to a repository, what would it be? Please explain how you arrived at your answer (since if all you did was pick a number, then I could have done that all by myself ;) ...

Unit testing a java servlet

I would like to know what would be the best way to do unit testing of a servlet. Testing internal methods is not a problem as long as they don't refer to the servlet context, but what about testing the doGet/doPost methods as well as the internal method that refer to the context or make use of session parameters? Is there a way to do ...