Hostname: page-component-89b8bd64d-ktprf Total loading time: 0 Render date: 2026-05-07T18:35:38.311Z Has data issue: false hasContentIssue false

Unit Testing in ASP Revisited: Language and Test-Driven Development Environment

Published online by Cambridge University Press:  02 April 2024

GIOVANNI AMENDOLA
Affiliation:
University of Calabria, Rende, Italy (e-mails: giovanni.amendola@unical.it, giuseppe.mazzotta@unical.it, francesco.ricca@unical.it, ricca@mat.unical.it)
GIUSEPPE MAZZOTTA
Affiliation:
University of Calabria, Rende, Italy (e-mails: giovanni.amendola@unical.it, giuseppe.mazzotta@unical.it, francesco.ricca@unical.it, ricca@mat.unical.it)
FRANCESCO RICCA
Affiliation:
University of Calabria, Rende, Italy (e-mails: giovanni.amendola@unical.it, giuseppe.mazzotta@unical.it, francesco.ricca@unical.it, ricca@mat.unical.it)
TOBIAS BEREI
Affiliation:
University of Applied Sciences Upper Austria, Campus Hagenberg (e-mails: tobias.berei@students.fh-hagenberg.at, bereitobias@hotmail.com)
Rights & Permissions [Opens in a new window]

Abstract

Unit testing frameworks are nowadays considered a best practice, included in almost all modern software development processes, to achieve rapid development of correct specifications. Knowledge representation and reasoning paradigms such as Answer Set Programming (ASP), that have been used in industry-level applications, are not an exception. Indeed, the first unit testing specification language for ASP was proposed in 2011 as a feature of the ASPIDE development environment. Later, a more portable unit testing language was included in the LANA annotation language. In this paper we revisit both languages and tools for unit testing in ASP. We propose a new unit test specification language that allows one to inline tests within ASP programs, and we identify the computational complexity of the tasks associated with checking the various program-correctness assertions. Test-case specifications are transparent to the traditional evaluation, but can be interpreted by a specific testing tool. Thus, we present a novel environment supporting test-driven development of ASP programs.

Information

Type
Original Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2024. Published by Cambridge University Press
Figure 0

Table 1. Base constructs of the annotation language

Figure 1

Table 2. Assertions for @test(…) annotation

Figure 2

Fig. 1. Testing graph coloring.

Figure 3

Fig. 2. Bugged encoding of Hamiltonian Cycle.

Figure 4

Table 3. Complexity results of the main tasks concerning ASP programs evaluation

Figure 5

Table 4. Computational complexity of the assertion tasks

Figure 6

Fig. 3. Architecture of ASP-WIDE.

Figure 7

Fig. 4. TestSuite class definition.

Figure 8

Fig. 5. Implementation of the @trueInAtMost assertion.

Figure 9

Table 5. Implementation of the assertions. P denotes the scope (i.e., the subprogram to test), $T_P$ the program built to implement the assertion, C a constraint, A a set of atoms, k, c, l are integers

Figure 10

Fig. 6. Customization of DLVWrapper according to the used ASP system.

Figure 11

Fig. 7. The ASP-WIDE interface.

Figure 12

Table 6. Employed assertions for each domain

Figure 13

Table 7. Modifications applied to generate mutants

Figure 14

Fig. 8. Successful and failed unit tests for each domain.

Figure 15

Table 8. Comparison between ASP-WIDE and ASPIDE-LIKE

Figure 16

Fig. 9. Assertion-based comparison between ASP-WIDE and ASPIDE-LIKE methods.