Facing pogress jdbc connectivity using the DbUnit library

hello Everyone. i am currently working on this ticket; Add more integration tests to the Patient and Person service · Issue #902 · I-TECH-UW/OpenELIS-Global-2 · GitHub
aim is to

  1. create dataset to provide dammy data for test at runtime and also create intergrations tests
  2. my approach this query was to use the DbUnit liabray to actuall read and inject the dammy data from the xml files to the database at runtime

howeveri run into some challenges

  1. Firstly I extend the DdTestClass

The data was not loaded to the database due postgres not running at port 5432. error: DbTestCase error - Pastebin.com
2. Secondly another suggestion was to extent DataSourceBasedDbTestCase because it’s more flexible manageable while working with databases in test cases but still here I got a driver Class is null error ; error - Pastebin.com
Let me share a link to my repository ; creacted a utitlity classand a dataset postgres failures · josephbate/OpenELIS-Global-2@44e52e9 · GitHub for when i extend the DdTestCase class

here are some screen shots for other class i extended


if there is any asistance or sugestions on this please share on this thread
Cc. @mozzymutesa

1 Like

Hello @segujja_joseph can you check @DataProvider functionality from TESTNG? this will help you to use dummy data parameterized into the test method.

How you do this?

Create a method and name it anything you want, annotate it with @DataProvider annotation from TESTNG and then return your dummy data you want from it to be used to different test classes dynamically.

Here is the example:

@DataProvider
private static final object getMoney() {
return new object {
{10, “USD”},
{20, “EUR”}
};
}

@Test(dataProvider = “getMoney”)
public void constructorShouldSetAmountAndCurrency(int amount, String currency) {
Money money = new Money(amount, currency);
assertEquals(money.getAmount(), amount);
assertEquals(money.getCurrency(), currency);
}

This data provider can be dynamically used.

Kindly let me know if this helps.

1 Like

hello @valens
thank you for this sugestion, alhtough in making intergration we are testing the service class against an actual data base that is to say we need to load data to the actual data base then call all the service method
unless i have got it correctly but using @DataProvider acts on in memory not the data base i may be wrong this but thats what i know of TestNG
you can enlighten me more of if otherwise and how we can relate with an actual data base

Great !! I was confused by the point that you need access on dummy data, but for integration tests TESTNG can’t serve you.

1 Like

alright then
thank you @valens if you have any more suggestion please feel free to share
Cc. @Moses_Mutesasira

Hello @segujja_joseph , it would be helpfull if you provide any error, i believe when you hover onto line 33 to 47, you will see an error.