unit-testing

Fluent NHibernate CheckProperty and Dates

I setup a NUnit test as such: new PersistenceSpecification<MyTable>(_session) .CheckProperty(c => c.ActionDate, DateTime.Now); When I run the test via NUnit I get the following error: SomeNamespace.MapTest: System.ApplicationException : Expected '2/23/2010 11:08:38 AM' but got '2/23/2010 11:08:38 AM' for Property 'ActionDate' ...

How to configure a OCUnit test bundle for a framework?

I've been developing a Mac OS X framework and I want to use OCUnit in my XCode 3.2.1 project. I've followed several tutorials on how to configure a OCUnit test bundle. The problem is that when I create a test case that uses a function that is defined in one of the framework's sources, I get a building error telling me that the symbol is ...

NUnit not obeying attribute inheritance

Hi, I have an issue with NUnit - wondering if anyone has any ideas. We're using NUnit 2.5.3.9345 and C# 3.5. Take the following code: public class UnitTestBase { [TestFixtureSetUp] public void SetUpTestFixture() { //Do something in base } } [TestFixture] public class SomeTestClass : UnitTestBase { [TestFi...

How do I escape ERB code in fixtures?

Hi, I have a simple fixture.yml label: body: "<%= variable %>" The issue is that the erb code is parsed as part of loading the fixture, but I actually want to body to be "<%= variable %>" un-interpolated. How do I escape this? -daniel ...

How to unit test?

Basically I have two main questions: What exactly should you unit test? How do you do it? The problem is I have several applications that rely in a database connection and/or are communication applications, which mean most of the test cases are integration tests (or so I think). Most classes are fairly simple by themselves, but the ...

Ending a JUnit Test

I have a "black box" of code that contains many threads. There is no method to "kill" the black box threads that I have found. I am passing data into the "black box" through junit and making sure that I am getting the expected outputs. Is there a way to gracefully exit the test case (It keeps it open in eclipse because of the threads ...

What are good online introductions to testing and Test Driven Development?

I'm looking for an online introduction to unit testing and TDD. I have virtually no experience with TDD, unit testing, or any other agile methodology. My development environment is C++ on Linux. If there's a quality introduction to unit testing and TDD that uses C++ as the example language, that'd be great. If not then a general intr...

Method specific logging

Environment: JUnit 4, JDK 6 I would like to log all test names (annotated with @Test) and figure out the amount of time taken to execute each tests executed by JUnit in a standard J2SE environment. Should I rely on in-built JDK logging Logger.entering / exiting with System.currentTimeInMillis or is there a better way to do this. ...

During Spring unit test, data written to db but test not seeing the data

I wrote a test case that extends AbstractTransactionalJUnit4SpringContextTests. The single test case I've written creates an instance of class User and attempts to write it to the database using Hibernate. The test code then uses SimpleJdbcTemplate to execute a simple select count(*) from the user table to determine if the user was per...

Using Ninject, if I create a custom provider must I ensure a single instance or can I use the SingleInstance attribute?

Hi I am hoping either Peter or Ruben sees this question as they seem to be the go to guys regarding Ninject. I needed to create a custom provider because I have a class that takes 4 arguments. The two can be injected because they are types but the other two are configuration parameters and are integers. They refer to timeouts in millise...

Which C# mocking framework takes best advantage of .NET 4?

I would assume that the more dynamic nature of .NET 4 would improve the possibility of mocking. (but I may be wrong) Are there mocking frameworks that take advantage of .NET 4? If yes, which does it best? Conversely, are there mocking frameworks that do not even run on .NET 4? ...

How can I test blades in MVC Turbine with Rhino Mocks?

I'm trying to set up blade unit tests in an MVC Turbine-derived site. The problem is that I can't seem to mock the IServiceLocator interface without hitting the following exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at System.Reflection.E...

How to unit-test a method that receives a FormCollection to upload a file?

Hello, I want to Unit-test a method like the following: public ActionResult StoreFile(FormCollection form, string _paginaAtual) { Session["MySession"] = 1 if (Request.Files["uploadedFiles"] != null) { //do something about the file } return View() } It's inside my "SomeController.cs" contr...

Could not find class when launch ".bat" file

I launch a ".bat" file to launch one java test the file contains : <path to java> -cp<all jar available in the classpath> org.junit.runner.JUnitCore <Package.classname> all jar are separated by ";" when I launch the ".bat"file ,I see the following message on the cmd window : JUnit version 4.6 Could not find class: tester.Test Tim...

Unit testing - when multiple projects all have their own set of App_Config files

Here's the situation: I've got a solution with multiple unit testing projects, each targeting a specific assembly in the application. These unit test projects require a set of App_Config* files in order to execute (i.e. connectionStrings.config, appSettings.config, etc). When I run the tests from within VS.NET using TD.NET or ReSharper,...

Is it ok to change method visibility for the sake of unit testing?

Many times I find myself torn between making a method private to prevent someone from calling it in a context that doesn't make sense (or would screw up the internal state of the object involved), or making the method public (or typically internal) in order to expose it to the unit test assembly. I was just wondering what the Stack Overf...

How do I test database migrations?

I'm using Migrator.NET to write database migrations for the application. Marc-André Cournoyer wrote: Like any code in your application you must test your migrations. Ups and downs code. Do it part of your continuous build process and test it on as many different databases and environment as you can. How do I do that? Say I ...

Is it possible to convert a SoapException to a FaultException with WCF?

I am migrating a web service client from WSE to WCF. I already modified the internal fault and error handling to deal with FaultExceptions instead of SoapExceptions. The project has an extensive suite of test cases to test the fault and error handling which still relies on SoapException. For various reasons, I'd prefer not to rewrite t...

Test call from abstract class to base class using rhino mocks

If have following class public abstract class MyBaseClass : BaseClass { public override string Test(string value) { return value == null ? value : base.Test(value); } } Using partial mocks I can actually test the first part of the Test-code (with value = null). Is it possible to test the fact that the call to the b...

Maven: How to test two modules with the same tests in a third module

Hi Imagine a maven project with 3 modules, an interface module and two different implementations of this interface in a module each. I could test each implementation in its own module, but the test cases are basically the same, because of the same interface. Is there a way to collect the test cases in a fourth maven module and test the...