Skip navigation

Looking at The Law of Demeter

Have you heard of The Law of Demeter? I haven’t until recently I’ve come across this term a few times in one day. Immediately I decided to take more closer look and get familiar myself with that term. It turned out that it’s not about ancient mythology… well… it’s named in honor of Demeter which [...]

How to write Evil, Unstable code

How to write evil code? It’s easy, follow the guidelines. :)
Conditional Slalom - Always, always, feel good when writing lengthy if branches and switch statements. These increase the number of possible execution paths that tests will need to cover when exercising the code under test. The higher the Cyclomatic complexity, the harder it is to test! When someone suggests to [...]

Database testing – putting everything together

Create – database instance is not necessary
Prepare – clean tables, load data to datasource
Assert – verify your datasource contains expected data

@Test
public void testGetCustomerFromDao()
{
//business dao object
final CustomerDao customerDao = new CustomerDao();

// initialize DbAssert
final DbAssert dbAssert = DbAssert.init(“org/testfw/TestSource.xml”);

// create a “fake” datasource. Stanalone instance of HSQLDB will be created (no database required).
final DbSource myTestSource = dbAssert.fake_source(“testSrc”,”org/testfw/testSourceSchema.sql”, getClass());

// [...]

More about database testing

Following up on DbAssert I’ve made a few changes to it. They are really minor ones.

Ability to add additional conditions like this:

dbAssert.condition(“id”, 1).addCondition(“name”, “John Doe”);

Another change which brings more real functionality is:

// checks if count of the records returned equals given value
dbAssert.assert_count(0);

So we’ve all here been using DbAssert for two months already and I think [...]

Making assertions against database data

I want to share what I’ve done working on my current project to verify data in a database. The application we’re developing relying on SOAP messages exchange where the messages contain information to be written in datasource (DB2, MSSQL, Postgres, AS/400 etc.) Yeah we’re using them all.
You can consider this as a mappping SOAP(Business document) [...]