unit-testing

Where can I find unit tests for Sun classes?

I'm writing an implementation of an interface provided by Sun and I'm wondering if anyone knows of the availability of unit tests for Sun's APIs. It would seem that such of thing would be available, but I'm having a hard time finding them. Specifically, I'm looking for BlockingQueue tests (ie: a test for LinkedBlockingQueue that I coul...

Python unittest with expensive setup

My test file is basically: class Test(unittest.TestCase): def testOk(): pass if __name__ == "__main__": expensiveSetup() try: unittest.main() finally: cleanUp() However, I do wish to run my test through Netbeans testing tools, and to do that I need unittests that don't rely on an environment se...

Unit-tests and validation logic

I am currently writing some unit tests for a business-logic class that includes validation routines. For example: public User CreateUser(string username, string password, UserDetails details) { ValidateUserDetails(details); ValidateUsername(username); ValidatePassword(password); // create and return user } Should my t...

Unit-testing private methods: Facade pattern

Lots of developers think that testing private methods is a bad idea. However, all examples I've found were based on the idea that private methods are private because calling them could break internal object's state. But that's not only reason to hide methods. Let's consider Facade pattern. My class users need the 2 public methods. They ...

Multithread a unit test

In order to test concurrency issues, I want to call the same method on two different threads at exactly the same time using a unit test. In fact I probably want to call the same method on several threads at the same time. I'm using Microsoft's built in unit tester for VS2008. My thoughts are that I would lock an object and then synchro...

How do I mock the Python method OptionParser.error(), which does a sys.exit()?

I'm trying to unit test some code that looks like this: def main(): parser = optparse.OptionParser(description='This tool is cool', prog='cool-tool') parser.add_option('--foo', action='store', help='The foo option is self-explanatory') options, arguments = parser.parse_args() if not options.foo: parser.error('--f...

Unit testing and mocking email sender in Python with Google AppEngine

I'm a newbie to python and the app engine. I have this code that sends an email based on request params after some auth logic. in my Unit tests (i'm using GAEUnit), how do I confirm an email with specific contents were sent? - i.e. how do I mock the emailer with a fake emailer to verify send was called? class EmailHandler(webapp.Reques...

How to output names of ruby unit tests

I have a unit test (example is modified Test::Unit documentation) require 'test/unit' class TC_MyTest < Test::Unit::TestCase def test_something assert(true) end end When I execute it, I get: Loaded suite C:/test Started . Finished in 0.0 seconds. 1 tests, 1 assertions, 0 failures, 0 errors I would like to get something li...

Using PowerMock or How much do you let your tests affect your design?

I've been a fan of EasyMock for many years now, and thanks to SO I came across references to PowerMock and it's ability to mock Constructors and static methods, both of which cause problems when retrofitting tests to a legacy codebase. Obviously one of the huge benefits of unit testing (and TDD) is the way it leads to (forces?) a much...

How should you write junit test cases for multiple implementation of the same interface?

Before asking question, let me explain the current setup: I have an service interface, say Service, and one implementation, say ServiceImpl. This ServiceImpl uses some other services. All the services are loaded as bean by spring. Now, I want to write junit test cases for the ServiceImpl. For the same, I use the applicationContext to g...

MS Test Inconsistent failing tests after changes when project is under source control?

I have noticed that if I have a set of regression tests and decide to change a property on one of my objects (DTO) from int to decimal for example - i make all the other changes and the tests pass like normal. But if this project is under source control (VSS specifically) this small change will cause something strange to happen... Simi...

How does Microsoft's Entity Framework inhibit test driven development?

MS's entity framework is considered among developers in the agile community to inhibit test driven development. It was famously attacked by an influential group of .Net developers for not being a true reflection of the principles of the agile movement. What are the main drawbacks that an agile developer faces when using the entity fr...

How to evangelize unit tests in the organization?

I love unit tests because I truly believe they promote code quality and design best practices. The problem is that many of my team lead colleagues think they are waste of time. We already had a few unit tests initiatives that failed due to team leads reluctant attitude. They argue that maintaining the tests doesn't worth the trivial bug...

Common libraries in a large team

Assume you have five products, and all of them use one or more of the company's internal libraries, written by individual developers. It sounds simple but in practice, I found it to be very difficult to maintain. How do you deal with the following scenarios: A developer unintentionally introduces a bug and breaks everything in produ...

How-To Mock WCF Services ?

How-to Mock WCF Services Proxies with Rhino Mocks ? ...

Does Resharper support RowTest?

Resharper doesn't recognise Rowtests, is this normal? Is there anyway to fix it? (other than splitting rowtest manually) ...

Mocking ConfigurationCollection

Hi, How can I Mock ConfigurationCollection with Rhino Mocks. I need to create an Expected ConfigurationCollection which contains 1 element in order to test if me Configuration contains that element. Thanks. Note : My ConfigurationCollection inherits from IEnumerable. public interface ICapalConfiguration { ICapalRepositoryConfigu...

How do I run Rails integration tests without dropping DB contents?

I've written some integration tests that I'd like to run against a copy of my prod database before I push to production. This lets me test all of my routes are still correct, all of the pages render without errors and some of the multipage workflows work as expected. When I run the integration tests it drops the database I've loaded and...

Cleaning up a database in django before every test method

By default when Django runs against sqlite backend it creates a new in memory database for a test. That means for every class that derives from unittest.TestCase, I get a new database. Can this be changed so that it is cleared before every test method is run? Example: I am testing a manager class that provides additional abstraction on ...

Unit testing drawing control

Based on my previous question here my new concern is how do I unit test my drawing code? ...