Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-09

Getting fpcunit test results into a database

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Hi list,

Is there existing code available for getting fpcunit test results into a database?

Otherwise I'm thinking of writing an XML importer that gets the test results and imports them into a database... handy for regression testing, I'd think.
Looking at the XML, that wouldn't be too difficult... but I'm not really an (FPC+) XML afficionado...

Thanks,
Reinier

Unknown author
to Reinier Olislagers
Reinier Olislagers wrote 10 lines
Hi list, Is there existing code available for getting fpcunit test results into a database? Otherwise I'm thinking of writing an XML importer that gets the test results and imports them into a database... handy for regression testing, I'd think. Looking at the XML, that wouldn't be too difficult... but I'm not really an (FPC+) XML afficionado...

Why use the XML importer ?

The better way is to write a Unit test listener that directly inserts everything in the database.

The XML/TXT/Latex output routines are just specialized listeners. All you need to do is create a listener that inserts into a database instead of writing XML/txt/latex...

Michael.

Graeme Geldenhuys
to Reinier Olislagers: Is there existing code available for getting fpcunit test results into a database?…
Reinier Olislagers wrote
Is there existing code available for getting fpcunit test results into a database?

No, but the Test Listener interface makes such an addition very easy.

Simply create a TDatabaseListener that implements the ITestListener interface. It's only 5 required methods to implement. Then simply register that test listener with the testing framework (via TestResult.AddListener() call), and it will be fed test results as they happen.

Each of those 5 ITestListerner methods will then insert records into the database as needed.

Regards,
- Graeme -

Reinier Olislagers
to Graeme Geldenhuys
Graeme Geldenhuys wrote 15 lines
On 2012-09-28 09:18, Reinier Olislagers wrote: > > Is there existing code available for getting fpcunit test results into a > database? No, but the Test Listener interface makes such an addition very easy. Simply create a TDatabaseListener that implements the ITestListener interface. It's only 5 required methods to implement. Then simply register that test listener with the testing framework (via TestResult.AddListener() call), and it will be fed test results as they happen. Each of those 5 ITestListerner methods will then insert records into the database as needed.

Ah, Listeners.... thanks. Is this listener concept something that's common to more xunit frameworks (junit... etc) or is it an fpcunit invention?

Going to dive into the fpcunit code then. Glad I asked ;)

Unknown author
to Reinier Olislagers
Reinier Olislagers wrote 20 lines
On 28-9-2012 10:43, Graeme Geldenhuys wrote: > On 2012-09-28 09:18, Reinier Olislagers wrote: >> >> Is there existing code available for getting fpcunit test results into a >> database? > > No, but the Test Listener interface makes such an addition very easy. > > Simply create a TDatabaseListener that implements the ITestListener > interface. It's only 5 required methods to implement. Then simply > register that test listener with the testing framework (via > TestResult.AddListener() call), and it will be fed test results as they > happen. > > Each of those 5 ITestListerner methods will then insert records into the > database as needed. Ah, Listeners.... thanks. Is this listener concept something that's common to more xunit frameworks (junit... etc) or is it an fpcunit invention?

It is common to NNNunit testing frameworks.

Michael.

Graeme Geldenhuys
to Reinier Olislagers: Ah, Listeners.... thanks. Is this listener concept something that's common to more xunit…
Reinier Olislagers wrote
Ah, Listeners.... thanks. Is this listener concept something that's common to more xunit frameworks (junit... etc) or is it an fpcunit invention?

I think the idea came from DUnit, though FPCUnit was heavily based on the JUnit design. DUnit2 and FPTest also use the listeners concept. In fact the latter two uses interfaces a lot more than FPCUnit, making some extensions much easier to implement.

I believe other xunit frameworks have similar ideas. Each test framework seems to use the best [most suitable] features of the language in question.

eg: Object Pascal based test frameworks use published properties, C# and Java uses class attributes etc to define test methods.

Regards,
- Graeme -