Amiga-Development

Please login or register.

Login with username, password and session length
Advanced search  

News:

Created for developers of all Amiga camps

Author Topic: Unit testing  (Read 607 times)

0 Members and 1 Guest are viewing this topic.

asrael22

  • Newbie
  • *
  • Posts: 31
    • View Profile
Unit testing
« on: August 13, 2017, 12:54:51 PM »

Hi.

What options do I have to follow a test-driven approach?
Is there a unit-testing framework or unit for FreePascal with a fast turnaround?


Manfred
Logged

asrael22

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Unit testing
« Reply #1 on: August 13, 2017, 06:26:45 PM »

OK, I found FPTest:
https://github.com/graemeg/fptest

Tried to compile it but some EpikTimer, which is a dependency, requires 'baseunix'.
That doesn't seem to be available on the Amiga distribution.

Any ideas?


Manfred
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: Unit testing
« Reply #2 on: August 14, 2017, 07:20:05 PM »

Tried to compile it but some EpikTimer, which is a dependency, requires 'baseunix'.
EpikTimer is a so called 3th party component and although some of those components compiles and work out of the box when compiling for Amiga/Aros/Morphos, a lot of them don't because of their platform dependency.

Quote
That doesn't seem to be available on the Amiga distribution.
Unfortunately one of the flaws that nowadays programmers seem to have is to follow this kind of flow in their code:
Code: [Select]
{$IFDEF WINDOWS}
// do window stuff]
{$ELSE}
// do linux stuff
{$ENDIF}
Or vice verse.

Either way our beloved platform (and any other platform that FPC/Lazarus supports) is 'f*cked' by this kind of programming style.

For example, if you would to compile this for windows it depends on queryperformancecounter native Windows api.

The fact that you are confronted with missing unit baseunix is not something that is missing for our Amiga platforms (unless perhaps when targeting bsd) but is caused by sloppy programming.

There should not be a unit baseunix for Amiga, et all.

Quote
Any ideas?
I've given it some though, but seem unable to locate functionality on amiga API that could mimic epiktimer. At least not with such high precision.

fwiw: epiktimer is a high resolution stopwatch component. e.g. measured time between start and stop moment is very precise. afaik it originates from Delphi, and Delphi was a product targeting windows only.

afaik ALB42 and Chain-Q are trying (or already succeeded to a certain extend) to get the standard fpc test-suite working. I don't believe we have a working unit test already/
« Last Edit: August 14, 2017, 07:31:42 PM by magorium »
Logged

asrael22

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Unit testing
« Reply #3 on: August 14, 2017, 07:35:10 PM »

Alright. Thanks for looking into this.

I thought I'd program something myself.
Something very simple, just some Assert statements into some Pascal unit.
Then I figured to test a Pascal unit a container 'program' must be created for either a number of units or one for each unit where the classes or code of the unit can be tested in separation.


Manfred
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: Unit testing
« Reply #4 on: August 14, 2017, 07:40:21 PM »

Well, you could of course take your queue from Graeme's link and either tear out the usage of epiktimer or implement a dummy.

More on that link to Graeme's unit test project that you provided can be found here (in case you did not know already).
Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: Unit testing
« Reply #5 on: August 14, 2017, 08:06:22 PM »

btw: before i forget.

We do have a dedicated wiki page for 3th party units/projects/components/classes that are compatible with our platforms (usually written in Pascal itself without any platform dependencies) which can be found here.

It's just that it is something that we never seem to get around to adding to that page. We either copy-paste what we need from other projects or write our own code. I have a long todo list, which either requires minor changes to the existing component/project, await further features of FPC itself or some things are rather difficult to implement on Amiga platform. Sometimes i get lost in my todo list  :-\
Logged

ALB42

  • Moderator
  • Newbie
  • *****
  • Posts: 39
    • View Profile
Re: Unit testing
« Reply #6 on: August 14, 2017, 08:31:39 PM »

oh there is an test unit in FPC already included, fcl-fpcunit which should work

https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-fpcunit/

FPC itself has a rather big unittesting suite running (>8000 tests), my jenkins server let it run for m68k-linux for every checking: https://home.alb42.de:8080/job/FPCTest_m68k-linux_FPU/ sadly because of the makefile magic it's only for Unices ;)

the easiest way to use that look into the package testcase of "rtl-objpas"

https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/rtl-objpas/tests/

and use that as example ;) Have fun.

Logged

magorium

  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: Unit testing
« Reply #7 on: August 14, 2017, 08:44:30 PM »

As seem to happen more often to me than i would like these days: thank you for the corrections ALB42 !
Logged

ALB42

  • Moderator
  • Newbie
  • *****
  • Posts: 39
    • View Profile
Re: Unit testing
« Reply #8 on: August 15, 2017, 09:06:01 PM »

na, not really a correction, just little bit more precise, the one from Greame is just the same with some addition I guess, he often do such thing.

@asrael22
is this ok for you?
Logged

asrael22

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Unit testing
« Reply #9 on: August 15, 2017, 10:18:02 PM »

na, not really a correction, just little bit more precise, the one from Greame is just the same with some addition I guess, he often do such thing.

@asrael22
is this ok for you?
Sure. I'll take a look at this.
Thanks.
Logged