unit-testing

How can i inject servletcontext in spring

I need to write a junit test for a rather complex application which runs in a tomcat. I wrote a class which builds up my spring context. private static ApplicationContext springContext = null; springContext = new ClassPathXmlApplicationContext( new String[] {"beans"....}); In the application there i...

What are good patterns or supporting fixtures to write unit tests for Maven plugins?

I'm developing a Maven plugin, and I realise I'm not sure how to write unit tests for it since I don't know how to exercise the functionality of the plugin except by just running Maven. How have other Maven plugin developers managed testing of their code? ...

Automating silverlight unit tests using StatLight and TeamCity

Hi, What is the best way to run silverlight unit tests automatically using team city? I have found StatLight which we had working well when we used cc.net, and it says that it has support for teamcity. Does this just mean the test results output file is compatible with teamcity? Do I need to create a command line runner to run the tes...

Django unit-testing with loading fixtures for several dependent applications problems

Hello! I'm now making unit-tests for already existing code. I faced the next problem: After running syncdb for creating test database, Django automatically fills several tables like django_content_type or auth_permissions. Then, imagine I need to run a complex test, like check the users registration, that will need a lof ot data tables...

Link seams in .NET

I just recently finished Michael Feathers' book Working Effectively with Legacy Code. It was a great book on how to effectively create test seams and exploit them to get existing code under test. One of the techniques he talk about was using "link seams". Basically the idea was that if you had code that depending on another library yo...

How do I fix my Unit Test to have global access to everything?

Usually when you add one (in Visual Basic), it pops up a message asking if you want to enable an option that lets the test access things like private methods etc. However, I am editing a solution that does not have this enabled. I'd like to enable it so my unit tests will work, but I can't find the setting. Can anyone tell me how to en...

Looking for documentation for writing database-related unit tests in .Net.

Hi, I have heard that MbUnit comes with pretty nice test decorators which allow writing db-related tests with ease. I am struggling to find good documentation with samples. Also, can the same thing be achieved with the latest Micosoft's Test package? Many thanks. ...

What should i do to test EasyMock objects when using Generics ? EasyMock

See code just bellow Our generic interface public interface Repository<INSTANCE_CLASS, INSTANCE_ID_CLASS> { void add(INSTANCE_CLASS instance); INSTANCE_CLASS getById(INSTANCE_ID_CLASS id); } And a single class public class Order { private Integer id; private Integer orderNumber; // getter's and setter's ...

Open source license for test code

I'm creating a project to house an iPhone library for common code for the iPhone... essentially it's a library that'll save people from finding solutions to common problems that amount to copying and pasting snippets of code. The site is located here: http://code.google.com/p/devkit-bb/ I licensed it under Eclipse, because fosters the e...

Have you been in cases where TDD increased development time?

Hello everyone :) I was reading http://stackoverflow.com/questions/2512504/tdd-how-to-start-really-thinking-tdd and I noticed many of the answers indicate that tests + application should take less time than just writing the application. In my experience, this is not true. My problem though is that some 90% of the code I write has a TON ...

Why not lump all service classes into a Factory method (instead of injecting interfaces)?

We are building an ASP.NET project, and encapsulating all of our business logic in service classes. Some is in the domain objects, but generally those are rather anemic (due to the ORM we are using, that won't change). To better enable unit testing, we define interfaces for each service and utilize D.I.. E.g. here are a couple of the ...

How to exclude unit tests from the WAR in with Google App Engine plugin?

Hi, I am using the Google Application Engine plugin for Eclipse 3.4, and I have added unit tests in my projects. The unit tests are in a source folder named tests, separated from the source folder src. But, in the war/classes that is generated, the tests classes are present. Is there anyway not to put test classes in the generated war/...

How can I mock this asynchronous method?

I have a class that roughly looks like this: public class ViewModel { public ViewModel(IWebService service) { this.WebService = service; } private IWebService WebService{get;set;} private IEnumerable<SomeData> MyData{get;set;} private void GetReferenceData() { this.WebService.BeginGetStaticReferenceData(GetRefe...

Is my code really not unit-testable?

A lot of code in a current project is directly related to displaying things using a 3rd-party 3D rendering engine. As such, it's easy to say "this is a special case, you can't unit test it". But I wonder if this is a valid excuse... it's easy to think "I am special" but rarely actually the case. Are there types of code which are genuine...

Is it possible to run NUnit 2.5.3 tests in Gallio?

When I try to run NUnit tests in Gallio I get this: Detected a probable test framework assembly version mismatch. Referenced test frameworks: 'nunit.framework, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77'. Supported test frameworks: 'nunit.framework, Version=2.5.0.0-2.5.2.65535', 'nunit.framework, Version...

Automatic testing of GUI related private methods

When it comes to GUI programming (at least for web) I feel that often the only thing that would be useful to unit test is some of the private methods*. While unit testing makes perfect sense for back-end code, I feel it doesn't quite fit the GUI classes. What is the best way to add automatic testing of these? * Why I think the only m...

Are TestContext.Properties usable ?

Using Visual Studio generate Test Unit class. Then comment in, the class initialization method. Inside it add your property, using the testContext argument. Upon test app startup this method is indeed called by the testing infrastructure. //Use ClassInitialize to run code before running the first test in the class [ClassInitia...

Embedded systems code with good unit tests?

I am looking at approaches to Unit Test embedded systems code written in C. At the same time, I am also looking for a good UT framework that I can use. The framework should have a reasonably small number of dependencies. Any great Open-source products that have good UTs? EDIT: Folks, thanks for the answers --I really appreciate the...

In a Rails unit test, how can I get a User fixture to load its associated Profile?

In the documentation concerning Fixtures (http://api.rubyonrails.org/classes/Fixtures.html) they provide the following example of using label references for associations: ### in pirates.yml reginald: name: Reginald the Pirate monkey: george ### in monkeys.yml george: name: George the Monkey pirate: reginald So following their...

Unit testing file operations - where to maintain mock directory structure?

I'm still new to Unit testing, and specifically PHPUnit as the testing framework. Suppose I'm building a unit test for a resource loader class. The class looks for resources to load in two directories (a global and a user-specific one). To test the class, I would like to set up a mock testing directory containing some resource files. I...