Unit testing and integration testing using JUnit, Liquibase, HSQLDB, Hibernate, Maven and Spring Framework

In this article I’d like to show you how to create integration tests using JUnit, Liquibase, HSQLDB , Hibernate, Maven and Spring Framework. We will create maven project, liquibase schema/data deployment to the in-memory database and run integration tests against this database using Spring ORM / Hibernate

Read the rest of this entry »

Advertisements

NMock extensions and .NET 4. Avoiding “magical” and hardcoded strings in property names

In the previous post I’ve shown how to avoid hardcoding method names while setting up NMock stubs. Now it’s time for properties.

Read the rest of this entry »

NMock extensions and .NET 4. Avoiding “magical” and hardcoded strings in method names

When I’ve started using NMock in my new dotnetneural project I’ve faced with “magical” strings in stubs. Fortunately .NET 4 framework allows us to avoid them totally.

Read the rest of this entry »

Factory method pattern – interesting appliance

Today I’m going to talk about factory method pattern and it’s very interesting appliance. Read the rest of this entry »

SyslogMessage unit testing

Before we continue on unit testing SyslogMessageMapper we need to perform basic testing of syslog Message itself. [done]

Read the rest of this entry »

More plans

I’ve created several helper methods for Database class:

  • truncateTable()
  • countRecords()

I’ve also created base class DatabaseBaseTest which uses those methods heavily.

As for unit testing, I’ve impelented SyslogSessionMapper tests for several methods, but refactoring base classes have taken too much time.

save() method internally uses insertSession() and updateSession() (for non-persistent / persistent sessions accodingly ). First method is tested, second my is my future plan. I also need to unit test save() method.

As for delete() method — there will be some difficulties. Before I delete session object I have to delete all related syslog messages (by session_id foreign key in “syslog” db table). Currently SyslogMessageMapper isn’t implemented, so I need manually insert records into syslog messages table for unit testing delete() method

Additionally we do need getLatestSession() method which will retrieved latest session object from database. SQL will looks like:


  select id,max(start_date),end_date from syslog_sessions