unit-testing

How to use maven resources also as test resources

I have a maven project that loads an xslt file and executes the transformation along with other processing on the result. Normally when the user runs the application, the user provides the xslt file path to be loaded. But I include some default xslt files bundled inside my application that the user can use without loading any external xs...

Testing and mocking private/protected methods. Many posts but still cannot make one example work

Hi, I have seen many posts and questions about "Mocking a private method" but still cannot make it work and not found a real answer. Lets forget the code smell and you should not do it etc.... From what I understand I have done the following: 1) Created a class Library "MyMoqSamples" 2) Added a ref to Moq and NUnit 3) Edited the Asse...

Get list of named queries in NHibernate

I have a dozen or so named queries in my NHibernate project and I want to execute them against a test database in unit tests to make sure the syntax still matches the changing domain/database model. Currently I have a unit test for each named query where I get and execute the query, for example: IQuery query = session.GetNamedQuery("Ge...

C++ - Is it possible to implement memory leak testing in a unit test?

I'm trying to implement unit testing for my code and I'm having a hard time doing it. Ideally I would like to test some classes not only for good functionality but also for proper memory allocation/deallocation. I wonder if this check can be done using a unit testing framework. I am using Visual Assert btw. I would love to see some samp...

Unit testing Google wave robots in Java

Any tips or best practices for unit testing Google Wave robots written in Java? I'm expecting to deploy on AppEngine, if that helps. I'm a fan of TDD but new to both Wave Robots and AppEngine, so I'm hoping to use TDD to help me explore the design space. ...

maven test cannot load cross-module resources/properties ?

I have a maven mantained project with some modules . One module contains one XML file and one parsing class. Second module depends on the first module. There is a class that calls the parsing class in the first module , but maven seems cannot test the class in the second module. Maven test reports : java.lang.NullPointerException at j...

Does JMockit have any drawbacks at all?

This comparison shows, that JMockit has several advantages over other frameworks. Are there also any advantages that one of the others (JMock, EasyMock, Mockito, Unitils, PowerMock + Mockito/EasyMock) has over JMockit? ...

where is "create instance" menu in visual studio 2010?

Hi, in visual studio 2008 there is a sub-menu called "create instance" which is resides in class designer. Today I've opened VS.net 2010 and then opened class designer and create my class over there and when I wanted to test my class with the help of "create instance" option there was no such option available in vs.net 2010. and I've g...

Handling learning curve for new developers

Our company likes to hire new developers, with no experience. We have a core set of skills that we try to get them up to speed with, like ASP.NET and WinForms - to teach basic programming, the .NET languages, and the things they'll need to maintain and write. We also try and mentor them through early projects, so they can learn from some...

Does MS Test provide a default value equals comparison?

I want to test for example int orderId = myRepository.SubmitOrder(orderA); orderB = myRepository.GetOrder(orderId); Assert.AreEqual(orderA, orderB); // fail Obviously I need a value comparison here, but I don't want to have to provide an overridden Equals implementation for all of my classes purely for the sake of testing (it wouldn...

unit, integration and system tests for PHP applications

Hi, We were given an assignment to develop a prototype for a customer community. It was suggested PHP as the programming language. (but we're not supposed to actually code it, just a prototype with documentation is required) I'm wondering what are the best practices/ tools used in Unit testing, Integration Testing and System testing for...

How do you unit test Scala in Eclipse?

I am learning Scala and would like to set up integrated unit testing in Eclipse. As far as I can tell from googling, ScalaTest is the way to go, possibly in combination with JUnit. What are your experiences with unit testing Scala in Eclipse? Should I use the JUnit runner or something else? ...

Rail test case fixtures not loading

Rails appears to not be loading any fixtures for unit or functional tests. I have a simple 'products.yml' that parses and appears correct: ruby: title: Programming Ruby 1.9 description: Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programs delivered fast, you should...

Moq for Silverlight doesn't raise event

Trying to write Unit test for Silverlight 4.0 using Moq 4.0.10531.7 public delegate void DataReceived(ObservableCollection<TeamPlayerData> AllReadyPlayers, GetSquadDataCompletedEventArgs squadDetails); public interface ISquadModel : IModelBase { void RequestData(int matchId, int teamId); void SaveData(); event DataReceived...

Stub web calls in Scala

I'm currently writing a wrapper of the Spotify Metadata API to learn Scala. Everything's fine and dandy but I'd like to unit test the code. To properly do this I'll need to stub the Spotify API and get consistent return values (stuff like popularity of tracks changes very frequently). Does anybody know how to stub web calls in Scala, th...

Is testability alone justification for dependency injection?

The advantages of DI, as far as I am aware, are: Reduced Dependencies More Reusable Code More Testable Code More Readable Code Say I have a repository, OrderRepository, which acts as a repository for an Order object generated through a Linq to Sql dbml. I can't make my orders repository generic as it performs mapping between the Linq...

FileNotFound Exception when using TestDriven.NET and NUnit

I'm Writing a simple pong game in C# and XNA 4.0 to learn unit testing. The tools used are TestDriven.NET and NUnit, all newest versions. The problem is, if I test the code with VS2010 internal debugger, everything runs fine, but when I use "Run Test(s)" from menu, the application chokes with error: Test 'WindowsGame1.Game1.TestGameMenu...

How to set a breakpoint in a Nunit test and step through with Visual WebDeveloper 2008?

I have written a NUnit test in Visual Web Developer 2008 Express. But when I run the test, it doesn't pause at the breakpoint I had set. It just keeps on running but at the breakpoint, I need a step-by-step view on the test. Could anyone please tell me how I can use breakpoints with NUnit? Thanks in advance! ...

What's the fastest way to test a code snippet in Visual Studio 2008?

My common scenario: I have a web app and a test project in the same solution. Maybe I'm missing something, but I can't test methods/snippets from the Immediate Window regardless of which project. MSDN alleges you can't use syntax like ?TestMethod123(args) from the Immediate Window while in web type project. So, why can't I throw a met...

Gradle java.util.logging.Logger output in unit tests

Dear All: Sorry this is probably a very simple question. I am using gradle http://www.gradle.org/ for my development environment. It works quite well! I have written a simple unit test that uses HtmlUnit and my own package. For my own package, I use java.util.Logger. HtmlUnit seems to use commons logging: http://htmlunit.sourceforge...