Skip to content

Q: how to perform tests in src file #11

@mirkov

Description

@mirkov

This is not an issue but a question:

In original lisp-unit I like to define tests for internal (unexpored function) below the function itself, in the same file. I use that for testing and for documentation.

Is that possible in lisp-unit2?

The following code demonstrates what I like to do in lisp-unit, and how I tried to achieve the same in lisp-unit2

(cl:in-package :cl-user)

(defpackage lu-example
  (:use :cl)
  (:documentation "Demonstrate that Lisp Unit test code can live in the same file and
  package as source code"))

(in-package :lu-example)

(defun foo () t)

(lu:define-test foo
    (lu:assert-true (foo)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defpackage :lu2-example-1
  (:use :cl)
  (:documentation "Demonstrate conflicts when I try to have Lisp Unit2 test code in the
  same file and package."))

(in-package :lu2-example-1)

(defun foo () t)

;; I am not surprised by this failure
(lisp-unit2:define-test foo () 
    (lisp-unit2:assert-true (foo)))

(defpackage :lu2-example-1.test
  (:use :cl)
  (:documentation "Lisp Unit 2 test package.  I will try to place test code in that
  package, but in the same file"))

;; I was hoping that this would work
(lisp-unit2:define-test foo (:package :lu2-example-1)
    (lisp-unit2:assert-true (foo)))

Thank you,

Mirko

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions