2017 June Release

Testing use cases with Unit TestsPermanent link for this heading

Fabasoft app.ducx unit tests allow automating the testing process to ensure correct working code throughout the whole development cycle. One even could adopt test driven development by implementing a unit test for the required functionality first.

Syntax

instance UnitTest reference {
  test = expression {...}
  testdata<tdid,tdcontent> = {...}
}

instance UnitTestGroup reference {
  tests = {...}
}


Unit tests are instances of the object class FSCDUCXUNIT@1.1001:UnitTest and identified by references. Each unit test consists of one test expression, which is stored in the property test.

Note: In unit tests the private flag of component objects is ignored.

The aggregate testdata consists of the string property tdid and the content property tdcontent.

A unit test group is an instance of the object class FSCDUCXUNIT@1.1001:UnitTestGroup and identified by a reference. A unit test group holds in the property tests a list of unit tests. All unit tests listed in the property tests are executed in the specified order, skipping tests with the property inactive set to true.

Example

objmodel APPDUCXSAMPLE@200.200
{
  import COOSYSTEM@1.1;
  import FSCDUCXUNIT@1.1001;

  instance UnitTest TestContentExtraction {
    test = expression {
      content zipfile = #TestContentExtraction.testdata[tdid == "zip”].tdcontent
      ...
    }

    testdata<tdid,tdcontent> = {
      { "zip", file("resources/data.zip") }
      ...
    }
  }

  instance UnitTest TestNoExecution {
    inactive = true;

    test = expression {
      ...
    }

  }

  instance UnitTestGroup TestGroupExtractions {
    tests = {
      TestContentExtraction,
      TestNoExecution
    }
  }
}


In a Fabasoft Folio Domain unit tests can be started manually. To do so, click Run Test on the context menu of the unit test or Run Tests on the context menu of the unit test group object.

Unit tests can be integrated into an automated build and test environment using Fabasoft app.ducx Ant tasks. Information about Ant tasks can be found in chapter “Fabasoft app.ducx Ant tasks”.