unit-testing

How can I override Perl's open() function but use the same filehandle for testing?

Hi, I am currently adding some unit tests to some legacy code and I find myself with the need to override an open function. The live code looks something like this. if ( !open( F, $filetoopen) ){ # do stuff with <F> } What I want to do is make sure that "F" contains a file handle that I have provided from my tests rather than wha...

TestNG and Spring 3

Hi guys, What is the best practice way to do unit testing with Spring? I assume the combination TestNG & jmockit with Spring 3 isn't bad, so that's what I'm doing right now, but if I'm off course selecting the tools for my fresh Spring project, please tell me right away. :-) Anyways, I've created an entity that I want to test, but I'm n...

visual studio generate test

is there any vs addins that can take a class and set up all the wiring to generate the test class and methods as well as mocking the dependencies, etc. this seems like something that can be automated. ...

Failed web service unit tests behind a proxy in Eclipse

I have a problem executing unit tests in Eclipse behind a proxy, as the classes used by the unit tests call some web services, which are behind a proxy. In Tomcat I can of course specify a proxy to be used, but when I run unit tests directly from Eclipse, the proxy configuration of Eclipse seems to be ignored. How can I configure my unit...

Alternatives to backdooring java access when unit testing.

I'm trying to unit test a class with a number of private methods. Each of the private methods can be rather extensive. I can either make the method package scoped (which causes a warning), or I can use the code below to test it: Method method = instance.getClass().getDeclaredMethod("methodName"); method.setAccessible(true); Object obje...

Testing Real Repositories

Hi, I've set up unit tests that test a fake repository and tests that make use of a fake repository. But what about testing the real repository that hits the database ? If this is left to integration tests then it would be seem that it isn't tested directly and problems could be missed. Am I missing something here? ...

Visual Studio unit testing - how to access external files?

I have data files used as input to my unit tests. These files are quite big and I don't want to copy them each time unit tests are executed. Tests are executed without deployment. So I can just put them into folder under my solution, and... how to obtain path to my solution (or test project source code) when unit test is executing? ...

Is there an easy way to switch from a class code to the corresponding Unit Test in VS2008?

Everything's in the title. I use MoreUnit in Eclipse which allow me to switch back and forth between a class and its unit test and I was wondering if anything like this was available in Visual Studio 2008. Thanks Alexandre ...

Do I have to unit-test classes without specific functionalities?

I am learning about unit-testing best-pratices (especially thanks to this post : What makes good unit-test?), because during my project we started to make unit-tests in a bit anarchic way. So now I have to get almost everything from the start to apply strong testing method. One question the quoted post did not answered was do I have to ...

Error : "javax.servlet.ServletException: Failed to load test suite [SampleTest], Reason is [Class not found "SampleTest"] "

Hi i am new to cactus and when i am using tomcat5.1 and have included all the necessary jars. But when i am trying to execute it, it is showing the error, Error : "javax.servlet.ServletException: Failed to load test suite [SampleTest], Reason is [Class not found "SampleTest"] " Please let me know what the problem is?? ...

Fixture loading works with loaddata but fails silently in unit test in Django

I can load the fixture file in my django application by using loaddata: manage.py loaddata palamut The fixture palamut.yaml is in the directory palamut/fixtures/ I have a unit test module service_tests.py in palamut/tests/. Its content is here: import unittest from palamut.models import * from palamut.service import * from palamut....

Nhibernate/Domain Objects generate test objects with random data from factory

We are doing some DDD at work and I am trying to find a good utility for generating Domain Objects with random data, or predefined data, and populating dependent objects. Example Usage: var user = DDDObjectFactory.CreateUser(); user.Name = "TestUser"; In our world, a user can not exist without a organization, so if there is no organi...

ASP.net: Unit testing with dependency on web service proxy class

Let's say I have a class like the following: public class Test{ private RemoteDoc.Documentation docService = new RemoteDoc.Documentation(); public Test(){} } So this makes it difficult to unit test because there is a dependency on the proxy class. You can pass in the object via the constructor like so: public class Te...

has_many while respecting build strategy in factory_girl

Situation # Models class User < ActiveRecord::Base has_many :items end class Items < ActiveRecord::Base belongs_to :user validates_presence_of :user_id end # Factories Factory.define(:user) do |u| u.name "foo" end Factory.define(:user_with_items, :parent => :user) do |u| u.items {|items| [items.association(:item), ...

Can I tell if all tests passed under Perl's Test::More?

I have a Perl test script written using Test::More. Right before exiting, and if all tests passed, I'd like to perform some cleanup actions. If any tests failed, I want to leave everything in place for troubleshooting. Is there a flag within Test::More, or some other best practice within a single test script, to tell if "all is well" ...

How do I get visual studio to not wait on temporarily blocked tests?

I'm relatively new to unit testing, and trying it on my personal projects. I want to unit test some concurrent methods (futures which run actions in the thread pool). To avoid the test method finishing before the thread pooled action, I'm blocking the test. Here is the actual blocking code: Private Shared Function BlockOnFuture(ByVal fu...

c#: How can I verify methods are called in a certain order?

I have the following class: public class Script { IPrinter _printer; public Script(IPrinter printer) { _printer = printer; } public void Print(TextWriter writer) { _printer.PrintComment(writer, "lolz"); writer.WriteLine("omg this complicates things"; _printer.PrintSpecial(writer)...

Subsonic 3 Active Record TestRepository identity column not icremented

I am Unit Testing with Subsonic 3.0.0.3. Unit tests ran as expected with record count assertions passing. However the testing framework does not auto increment identity columns. For example var p1 = new Person() { Name = "Jack" }; p1.Add(); var p2 = new Person() { Name = "Jill" }; p2..Add(); var t1 = Person.SingleOrDefault(p => p.Nam...

Merge several mstest trx files into a single trx file

We use Visual Studio 2008 and MSTest. We have a batch file that the developers use to get latest version, build solution, run database scripts and run all tests. The problem is that we have many test projects. So at the end the developer must open each trx file to check if anything failed. Is there a way to write all test results to a...

C#: How do you test the IEnumerable.GetEnumerator() method?

Let's say I for example have this class that generates Fibonacci numbers: public class FibonacciSequence : IEnumerable<ulong> { public IEnumerator<ulong> GetEnumerator() { var a = 0UL; var b = 1UL; var c = a + b; while (true) { yield return c; c = a + b; ...