unit-testing

Unit testing both the presence/absence of a library

The question: Is there a way I can use a ClassLoader to test both the presence and absence of the library I'm checking for? I have a some code which will use a particular library if available, or fall back to some embedded code if not. It works fine but I'm not sure how to unit test both cases in the same run, or if it's even possible. ...

How to add a new column in a file

I have file like this which contains 5 columns. But some rows in my file have 4 columns by mistake, for example in this file at the 5th and 6th rows, you can see that the second column is missing. I want to replace the missing 2nd column with a blank space without disturbing other rows in my file with field separator ",". 11111,5323,62...

using JNDI when websphere is shutdown

I am trying to test my we based project.I have created main method and its call some db related classes.Now the db related classes uses JNDI , so when running the code i get exception Can i use JNDI when websphere server is stopped?If now how can i go about it?i dont want to run entire flow, i want to test my functionality by calling cl...

Problems with running Android Activity unit-testing from Eclipse

Hi Im having a problem starting or running any activity unit tests from within eclipse. Even i start a clean project and make a simple test class it always prints to the console: [2010-10-05 13:10:24 - testAndroid] Collecting test information [2010-10-05 13:10:25 - testAndroid] Test run failed: Test run incomplete. Expected 2 tests, r...

Cannot load dbghelp.dll when debugging unit test

I am unable to start my unit tests in debug mode in Visual Studio 2010 running on a Windows 7 x64 machine. If I run the unit tests in debug mode I get a BadImageFormatException: Could not load file or assembly 'dbghelp.dll' or one of its dependencies. The module was expected to contain an assembly manifest. at System.Reflection.Assembl...

Code Coverage when using NUnit to test unmanaged C++

My team is currently using CppUnit for all our unmanaged C++ unit tests but I'm toying with the idea of transitioning to NUnit through either GenTestAsm (pure C#) or C++/CLI. Either way, what consequences would I face on the Code Coverage front with either of these approaches? We currently use PureCoverage to instrument our unmanaged...

Running unit tests after local build with Visual Studio 2010

Using Visual Studio 2010, is there a way to run all unit tests in a solution automatically after building the solution locally? ...

How to unit test client-side jQuery/Javascript inside ASP.NET MVC?

Microsoft has really been pushing ASP.NET MVC, and one of its major strengths over ASP.NET Web Forms is unit testing. Then, they announced that they would support jQuery as their official client-side library for the platform, automatically including the source in new projects. Recently, they announced their first official contributions t...

gmaven no test found

Hi i m running into some error I have a really small project in groovy. I want to use maven. I was able to compile my files, source and test(i have my .class in the target folder). But no test are executed. here is my pom file. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w...

PHPUnit StackTest::assertEmpty() deprecated.

I am learning building php unit tests using PHPUnit . There they have a manual and I encountered this example Where they use assertEmpty(), but when I run this code in command line I get this error : Call to undefined method StackTest::assertEmpty() in /var/www/.../tests/StackTest.php on line 20. So if this method is deprecated or someth...

Unit Testing - Arranging objects that are inaccessible to the test project

I am writing a card game in an attempt to learn Silverlight. I have domain representation of the game which is exposed to Silverlight as a WCF service and the only public method on my Game object is "PlayCards". Which is a method that looks like this public void PlayCards(Guid playerId, List<Card> cards) When this method is invoked, ...

Unit testing the tower of hanoi problem

Hi, If I was unit testing the tower of hanoi problem, what would be the best cases? I can test the parameters and the general expected output of the method, but is it possible to test anything else? So I could test: Output is correct (algorithm has worked), arguments are of the correct assumption (ie not null), anythine else? Thanks ...

Visual Studio 2010 Pro: Shared test project, but developer-specific connection strings

Hi, We have multiple developers working on the same unit test project that have unique database connection strings and user credentials. What's the best way to store this information on a per-developer basis on their local machines, so we're not always editing a source file that gets checked into our VCS and (hopefully) reverting our c...

Are Using Interfaces Soley to Facilitate Stubing and Mocking in Unit Tests Now Obsolete?

In .NET, TypeMock Isolator and Microsoft Moles allow one to isolate any class, property, or method - be it sealed, static, protected or non-virtual. So what was impossible to mock in Moq or Rhino Mocks, now no longer is the case. I've always had some aversion with the idea of using an interface merely to be able to allow for mocking, wh...

Visual Studio Unit Test - Weird behaviour

Has anyone seen this very strange behaviour before? I've got a solution whith 70 unit tests. All of them pass on my dev machine. Whenever I commit my changes, our continuous integration process kicks in and the build box will eventually run the same 70 unit tests. There is only ONE test in the build box that fails all the time. The err...

whas the actual use of 'fail' in junit test case?

whas the actual use of 'fail' in junit test case? ...

Entity Framework (POCO) + Unit Testing = Collection was modified exception

I have an app that uses EF POCO for accessing data. Everything works great, yet there is one problem with unit testing. Imagine two related classes: public class Brother { public virtual Sister Sister { get; set; } } public class Sister { public virtual ICollection<Brother> Brothers { get; set; } } The problem here is that if...

Unit testing Spring 3 database methods

I have abstract class that defines database methods, such as inserts and updates, and a concrete class that implements it. The database configurations (dataSource, DatabaseTarget etc) are defined as beans in context.xml-file. The database with its methods work in Controller when I'm using Spring 3 anotations by private AbsractClass a;...

Faking constructors for unit testing

Hi, I have a set of classes that have dependencies at instantiation time, that is, when creating an object of type A, it also creates another of type B, which subsequently creates others of type C, etc. For testing matters, I don't need the whole functionality of all the levels to test the upper ones, so I could use stubs or mocks, bu...

Why phper does not care test ?

In Java or Ruby, there are many talks about test/TDD/BDD. and there are many tests in Java/Ruby projects. But I notice that, there are less tests in PHP project, and It seems like PHPer does not like to write tests, I just want to know the reason. thanks ...