Skip to content

Experimentation of running Caché ObjectScript unit testing with coverage information

Notifications You must be signed in to change notification settings

ARechitsky/cache-utcov

 
 

Repository files navigation

What this is

The goal of this package is to provide a framework, runnable from at least the Caché terminal, to be able to:

  • run unit tests on a particular project, and
  • collect code coverage information.

Why

Unit tests are an accepted practice to validate your code; coverage information further helps developers/software engineers to identify "grey areas" in the code; that is, code which unit tests do not cover.

Caché has a builtin mechanism to both run unit tests and collect trace information; but, unlike other major programming languages, it does not provide a convenient way to link unit test execution and code coverage.

This package intends to fill the gap.

How

At this point in time, the mechanism is not fully defined.

It is known however that Caché has what it takes to perform the task:

  • The %Studio.Project class can list all of the elements in a given project; this includes all COS classes, including test cases, which all inherit %UnitTest.TestCase.
  • The ZBREAK command can be used to collect traces in INT code in a non interactive manner, and to a dedicated device (and that includes a file): zbreak /TRACE:ON:thefile.

Those two elements and others can be used to perform a full unit test run and coverage report.

Entry points

At the moment there are two entry points:

  • Collect all production and test classes and print them to the terminal:

    do ##class(utcov.Main).m3()
    

    This method collects classes from project "cache-tort-git" in namespace "USER" (you can change it in src/utcov/Main.cls)

  • Run unit tests with coverage

    do ##class(UnitTest.Main).Run()
    

    This method run unit tests from class UnitTest.SampleUnitTest class and collects coverage information from UnitTest.SampleTestedClass You can see coverage information at <cache server>:<cache port>/csp/<your namespace>/utcov.UI.SimpleResultViewer.cls

Help needed

The code as it stands is still a proof of concept. Right now it consists of various tidbits which have to be plugged in together so as to ultimately form a coherent, usable module.

Feedback is welcome. In this order, you want to:

About

Experimentation of running Caché ObjectScript unit testing with coverage information

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Apex 89.2%
  • TeX 6.6%
  • Shell 4.2%