unit-testing

Best way to unit test Collection?

I'm just wondering how folks unit test and assert that the "expected" collection is the same/similar as the "actual" collection (order is not important). To perform this assertion, I wrote my simple assert API:- public void assertCollection(Collection<?> expectedCollection, Collection<?> actualCollection) { assertNotNull(expectedC...

Intelligent serial port mocks with Moq

I have to write a lot of code that deals with serial ports. Usually there will be a device connected at the other end of the wire and I usually create my own mocks to simulate their behavior. I'm starting to look at Moq to help with my unit tests. It's pretty simple to use it when you need just a stub, but I want to know if it is possib...

Testing Hibernate DAO, without building the universe around it.

We have an application built using spring/Hibernate/MySQL, now we want to test the DAO layer, but here are a few shortcomings we face. Consider the use case of multiple objects connected to one another, eg: Book has Pages. The Page object cannot exist without the Book as book_id is mandatory FK in Page. For testing a Page I have to cr...

Advice on Mocking System Calls

I have a class which calls getaddrinfo for DNS look ups. During testing I want to simulate various error conditions involving this system call. What's the recommended method for mocking system calls like this? I'm using Boost.Test for my unit testing. ...

organize using directives, re-run tests?

Before making a commit, I prefer to run all hundred-something unit tests in my C# Solution, since they only take a couple minutes to run. However, if I've already run them all, all is well, and then I decide to organize the using directives in my Solution, is it really necessary to re-run the unit tests? I have a macro that goes throug...

How do I get my non MSTest unit tests running on .net 4.0

Has any of the alt.net unit testing frameworks embraced .net 4.0 framework? ...

Embeddable unit testing framework for mixed Windows app

I want to test portions of a very complex app which includes both a major native Windows component and a substantial WPF GUI. Due to complexities I can't detail, it is impossible to run the native portion independently nor can I isolate the areas I want to test (spare me the lectures, we're talking a huge legacy code base and we do have ...

Assertions (contracts) and unit testing

Say I have a method public void PrintStuff(string stuff, Color color, PageDimensions dimensions) { Assert.IsNotNull("color"); Assert.IsNotNull(dimensions); Assert.IsTrue(dimensions.width < 20.0); } and I have another method AnotherMethod() which is calling PrintStuff(). Let's assume PrintStuff() is defined in some inter...

make maven's surefire show stacktrace in console

Id like to see stacktrace of unit tests in console, does surefire support this? ...

C# Unit Test framework for Visual Studio?

Hallo all, My director told me that there is a Unit Test framework for Visual Studio from Microsoft, but didn't know what is the name of this tool. Could anyone of you give a hint on it? Thanks in advance, John ...

Is it possible to profile memory usage of unit tests?

I'm looking at building some unit tests to ascertain if resources are leaking (or not) using the unit testing framework that comes with Visual Studio. At present, I'm evaluating the latest version of ANTS Profiler, but I can't quite work out if it allows me to force a snapshot from code (so that I can take a snapshot, run a unit test a ...

Using Selenium, how can I test a web UI that returns XML instead of HTML?

I'm using Selenium to unit test my Perl cgi script and all works fine except in one special test case where my cgi script returns XML content to the web browser instead of returning HTML content. I'm new to Selenium and only pasted in their sample script to get started, but I can't seem to find a Selenium command in any of the documen...

Is there an alternative to publicize.exe?

The Visual Studio unit test tool publicize.exe appears to be unsupported. Bugs aren't getting fixed in it and I'm hitting blocking bugs where it crashes when creating private accessor assemblies for perfectly valid assemblies. Do any alternative tools exist for publicize.exe? (I'm aware of InternalsVisibleTo, and the arguments for...

Missing Test Settings template in VS2010 Ultimate

I'm attempting to add a Test Settings file to my Unit Tests project in VS2010. All websites seem to simply say "Go to Add New Item > Installed Templates > Test Settings". However, I don't have Test Settings as an option in my Installed Templates (nor does searching for them online turn up any results). Can someone point me in the righ...

White-box testing in Javascript - how to deal with privacy?

I'm writing unit tests for a module in a small Javascript application. In order to keep the interface clean, some of the implementation details are closed over by an anonymous function (the usual JS pattern for privacy). However, while testing I need to access/mock/verify the private parts. Most of the tests I've written previously have...

Ways to Unit Test Oauth for different services in ruby?

Are there any best practices in writing unit tests when 90% of the time I'm building the Oauth connecting class, I need to actually be logging into the remote service? I am building a rubygem that logs in to Twitter/Google/MySpace, etc., and the hardest part is making sure I have the settings right for that particular provider, and I wo...

using a Singleton to pass credentials in a multi-tenant application a code smell?

I'm currently working on a multi-tenant application that employs Shared DB/Shared Schema approach. IOW, we enforce tenant data segregation by defining a TenantID column on all tables. By convention, all SQL reads/writes must include a Where TenantID = '?' clause. Not an ideal solution, but hindsight is 20/20. Anyway, since virtually e...

Unit Testing And Starting MongoDb Server

I am running some unit test that persist documents into the MongoDb database. For this unit test to succeed the MongoDb server must be started. I perform this by using Process.Start("mongod.exe"). It works but sometimes it takes time to start and before it even starts the unit test tries to run and FAILS. Unit test fails and complains ...

Why are my functional tests failing?

I have generated some scaffolding for my rails app. I am running the generated tests and they are failing. for example test "should create area" do assert_difference('Area.count') do post :create, :area => { :name => 'area1' } end assert_redirected_to area_path(assigns(:area)) end This test is failing saying ...

Any good arguments for not writing unit tests?

I have read a lot of threads about the joys and awesome points of unit testing. My question is, does anyone have a good argument against unit testing? ...