unit-testing

ruby Test::Unit Command line options?

Hi all, When running tests in Ruby's unit::test framework, is there a really easy way to specify, from the command-line, that only one test should be run (that is, specify the test class and test member variable)? If not, is there another framework that has this feature? ...

How to deal with code coverage?

The other day we had a hard discussion between different developers and project leads, about code coverage tools and the use of the corresponding reports. Do you use code coverage in your projects and if so, why not? Is code coverage a fixed part of your builds or continous integration or do you just use it from time to time? How do y...

Force JUnit to run one test case at a time

I have a problematic situation with some quite advanced unit tests (using PowerMock for mocking and JUnit 4.5). Without going into too much detail, the first test case of a test class will always succeed, but any following test cases in the same test class fails. However, if I select to only run test case 5 out of 10, for example, it wil...

How to unit test ASRs On Pivotal CRM

Hi, I am using Pivotal CRM and I do not find easy ways to code unit test for its ASRs for this software. Do you have any experience programming test for this software? Edit: I have thought a simple but not perfect way of testing. But I am willing to give the Bounty to anybody who gives the minimun insight. ...

Testing objects with dependencies in PHPUnit

For objects which compose another object as part of their implementation, what's the best way to write the unit test so only the principle object gets tested? Trivial example: class myObj { public function doSomethingWhichIsLogged() { // ... $logger = new logger('/tmp/log.txt'); $logger->info('some mess...

How can I execute silverlight unit tests from the command line

I've a set of tests for a silverlight application that use Silverlight's test framework. I can execute these from within visual studio and they run beautifully. I can also build my code from outside Visual studio using MSBuild following the tips in Jeff Wilcox's blog post: http://www.jeff.wilcox.name/2009/01/silverlight-msbuild-tricks-...

Assert IEnumerables

As unit testing is not used in our firm, I'm teaching myself to unit test my own code. I'm using the standard .net test framework for some really basic unit testing. A method of mine returns a IEnumerable<string> and I want to test it's output. So I created an IEnumerable<string> expected to test it against. I thought I remembered there...

Is this unit test excessive?

Given the following SUT, would you consider this unit test to be unnecessary? **edit : we cannot assume the names will match, so reflection wouldn't work. **edit 2 : in actuality, this class would implement an IMapper interface and there would be full blown behavioral (mock) testing at the business logic layer of the application. this...

Unit testing a web site

I'm curious to see how other developers go about testing their web sites (PHP specifically in my case, but this probably spans multiple languages)? I've been working on a site for over a year now and I'd really like to automate a lot of the regression testing I do between versions. This specific site is in code igniter, an MVC framewor...

Automating VB6 application with ActiveX controls

I have a VB6 application that I don't have source code. This application uses third-party ActiveX controls. I want to automate these ActiveX controls. Is it possible to get the IUnknowns or Object references? For some of these, I can get the underlying HWNDs, but from what I can tell there isn't a generic way to convert these HWNDs to th...

How do you test your business objects?

I am wanting to implement automated testing, using the Microsoft testing framework in Visual Studio, for my software development projects. I have created some tests, and all in all, it's pretty easy to use. What are some better practices for testing business objects, more specifically ones that read and write to a database. Is it best ...

How do you avoid duplicate unit tests when testing interactions on composites?

Imagine a system of filters (maybe audio filters, or text stream filters). A Filter base class has a do_filter() method, which takes some input, modifies it (perhaps), and returns that as output. Several subclasses exist, built with TDD, and each has a set of tests which test them in isolation. Along comes a composite class, of an unr...

What is the recommended way to log data that caused errors in JUnit?

I'm relatively new to JUnit, and I was writing a few of my first tests today. For some particular method, I wanted to pass random values (all of which are within the correct range). If the method fails for any reason, I want to know which value caused it to fail. So what's the recommended way of doing this? (Or is it bad to use random v...

How / if to refactor a Delphi program using only forms and data modules

After years of coding Delphi programs as untestable code in forms and datamodules, including global variables, and the only classes are the forms themselves, containing all the code I need for the form UI itself. How would I convert the code to a set of classes that do the actual work? would I need to stop using the datasources/datasets...

Django unittest assertRaise for a custome error

I have defined a custom error but if I test if custom error gets raised, it fails. My models.py: class CustomError(Exception): """ This exception is my custom error """ class Company(models.Model): name = models.CharField(max_length=200) def test_error(self): raise CustomError('hello') and in my tests.py: i...

Getting a list of all modules in the current package

Here's what I want to do: I want to build a test suite that's organized into packages like tests.ui, tests.text, tests.fileio, etc. In each __init__.py in these packages, I want to make a test suite consisting of all the tests in all the modules in that package. Of course, getting all the tests can be done with unittest.TestLoader, bu...

"Unit testing" a report

How would you "unit test" a report created by some report engine like Crystal Reports or SQL Server Reporting Services? ...

What type of errors could my code still contain even if I have 100% code coverage?

Looking for concrete examples or links to concrete examples of such errors. Thanks in advance. ...

Do you need to do unit and integration testing if you already do functional testing?

People at my company see unit testing as a lot of extra work, that offers fewer benefits than existing functional tests. Are unit and integration tests worth it? Note a large existing codebase that wasnt designed with testing in mind. ...

Make pyunit show output for every assertion

How can I make python's unittest module show output for every assertion, rather than failing at the first one per test case? It would be much easier to debug if I could see the complete pattern of failures rather than just the first one. In my case the assertions are based on a couple loops over an array containing an object plus some f...