comp.lang.ada
 help / color / mirror / Atom feed
From: Tero Koskinen <tero.koskinen@iki.fi>
Subject: Re: ANN: Ahven 1.8
Date: Fri, 4 Jun 2010 18:37:08 +0300
Date: 2010-06-04T18:37:08+03:00	[thread overview]
Message-ID: <20100604183708.2ff8bfd3.tero.koskinen@iki.fi> (raw)
In-Reply-To: 827hmf17i8.fsf@stephe-leake.org

On Fri, 04 Jun 2010 05:17:51 -0400 Stephen Leake wrote:

> Dan <dan@irvine.com> writes:
> 
> > On Jun 3, 5:08 am, Stephen Leake <stephen_le...@stephe-leake.org>
> > wrote:
> >> How does it compare to AUnit?

Here a little summary:
 * The basic API is similar in Ahven and AUnit 1 (and 3).
 * In Ahven, I have the public API stuffed into two packages:
   Ahven and Ahven.Framework while AUnit spreads it API into
   larger amount of packages.

 * AUnit is Ada 2005 code only and I think it can be compiled
   only with GNAT (not 100% sure since I haven't tried it with
   other Ada 2005 compilers)
 * Ahven is Ada 95 code, but can be compiled as Ada 2005 code also.
   I have seen some effort to make Ahven build out of the box
   with several Ada 95 or Ada 2005 compilers. So far, GNAT,
   Janus/Ada, ObjectAda, and ICCAda have been tested.
   (Unix and Windows environments)
   
   I don't know about IBM/Rational Apex, GHS AdaMulti, or PowerAda,
   but I suspect that they should be okay also.

 * Both are free or open-source software.
   AUnit is distributed under GPL and  Ahven under ISC
   license (similar to BSD).

 * Both libraries support XML results, but AUnit uses CppUnit's
   XML format while Ahven uses JUnit's format.
   In addition, Ahven can output test results in
   Test-Anything-Protocol (TAP) format, which is my favorite
   at the moment.

 * AUnit's documentation is probably better. So far I have
   concentrated on the code.

> In AUnit, tests are 'registered' in a test_case:
> 
>    overriding procedure Register_Tests (T : in out Test_Case)
>    is
>    begin
>         Register_Routine (T, Nominal'Access, "Nominal");

Same works for Ahven. Dan's example was just somewhat exotic, so
one couldn't figure it out from that.

   procedure Initialize (T: in out Test_Case) is
      procedure Register_Routine
        (T       : in out Ahven.Framework.Test_Case'Class;
         Routine :        Simple_Test_Routine_Access;
         Name    :        String) renames Ahven.Framework.Add_Test_Routine;
   begin
      Register_Routine (T, Nominal'Access, "Nominal");
      ...;

The difference is in the test routine signature.

AUnit accepts only form
procedure Nominal (T : in out AUnit.Test_Cases.Test_Case'Class);

while Ahven accepts
procedure Nominal (T : in out Ahven.Framework.Test_Case'Class);
 and
procedure Nominal;

> Then test_cases are added to suites:
> 
>    Add_Test (Suite, new Test_Hardware.Analog_In_Out_Wrappers.Test_Case);
>    Add_Test (Suite, new Test_Hardware.Analog_In_Wrapper_Common.Test_Case);
>    Add_Test (Suite, new Test_Hardware.Analog_Out_Wrapper_Common.Test_Case);
> 
> This seems roughly equivalent to Ahven. 

Yes.

> AUnit also has setup and teardown functions for initializing and finalizing
> each test and/or each Test_Case; those are very helpful.

Ahven supports setup and teardown procedures for each test.

For each Test_Case you need to rely on Initialize and Finalize
procedures provided by Ada.Finalization.Controlled.

package body Simple_Tests is
   type Test_Access is access all Test;

   procedure Initialize (T : in out Test) is
   begin
      Set_Name (T, "Simple Tests");

      Ahven.Framework.Add_Test_Routine
        (T, Test_Assertion'Access, "Test Assertion");
      Ahven.Framework.Add_Test_Routine
        (T, Test_With_Object'Access, "Test With Object");
      Ahven.Framework.Add_Test_Routine
        (T, Test_Error'Access, "Test Error (exception)");

   end Initialize;
   
   procedure Set_Up (T : in out Test) is
   begin
      Put_Line ("Simple_Tests.Set_Up");
      T.Value := 1;
   end Set_Up;
   
   procedure Tear_Down (T : in out Test) is
   begin
      Put_Line ("Simple_Tests.Tear_Down");
      T.Value := -1;
   end Tear_Down;
   
   procedure Test_Assertion is
   begin
      Put_Line ("Test_Assertion");
      Ahven.Assert (False, "assert(false)");
   end Test_Assertion;
   
   procedure Test_Error is
   begin
      raise Constraint_Error;
   end Test_Error;

   procedure Hello (T : Test) is
   begin
      Ahven.Assert (T.Value = 1, "T.Value = 1");
   end Hello;
   
   procedure Test_With_Object (T : in out Ahven.Framework.Test_Case'Class) is
   begin
      Put_Line ("Test_With_Object");
      Hello (Test (T));
   end Test_With_Object;
end Simple_Tests;


There are probably also other differences, but
I don't want to spoil too much. ;)

> -- 
> -- Stephe


-- 
Tero Koskinen - http://iki.fi/tero.koskinen/



  reply	other threads:[~2010-06-04 15:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-02 16:24 ANN: Ahven 1.8 Tero Koskinen
2010-06-03 12:08 ` Stephen Leake
2010-06-03 19:36   ` Dan
2010-06-03 19:43     ` Dan
2010-06-04  9:17     ` Stephen Leake
2010-06-04 15:37       ` Tero Koskinen [this message]
2010-06-05 12:41         ` Simon Wright
2010-06-05 19:17           ` Ludovic Brenta
2010-06-06 12:31             ` Stephen Leake
2010-06-06 16:20               ` Ludovic Brenta
2010-06-06 16:45                 ` Simon Wright
2010-06-06 17:48                   ` Ludovic Brenta
2010-06-07  8:26                 ` Stephen Leake
2010-06-07 19:21                   ` Simon Wright
2010-06-04 17:12       ` Dan
2010-06-05  4:08         ` Stephen Leake
2010-06-08 15:24 ` Jérôme Haguet
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox