[lift-devel] Multiple values testing for the same code

Gary King gwking at metabang.com
Sun Mar 18 14:00:30 UTC 2012


Hi Necto,

There isn't a super beautiful way to do this in LIFT (at least, not that I've come up with!).

Two things come to mind:

1. make a test-suite like

(deftestsuite percl-db-test (percl-test)
	(db-class *db*)
  (:setup 
  (setf *db* (make-instance db-class)))

(addtest (percl-db-test) store ...)
(addtest (percl-db-test) load ...)

then make a new test suite

(deftestsuite percl-db-test-runner (percl-test)
  ())

(addtest (percl-db-test-runner)
  test-mem-db 
  (let ((*test-result* (run-tests :suite 'percl-db-test :testsuite-initargs '(:db-class 'mem-db))
   -- make sure there were no failures and errors --
   ))

There are examples like this in the LIFT test-suite

2. use ensure-cases

(deftestsuite percl-db-test (percl-test)
  ())

(addtest (percl-db-test) store  
    (ensure-cases (class) 
     '(mem-db sql-db)
    (let ((*db* (make-instance class))) ...))

Using a macro to handle the boilerplate for the second idea will make it look fairly elegant :-)


HTH,


On Mar 18, 2012, at 8:22 AM, necto wrote:

> Hello, everyone!
> 
> I need the following thing:
> I had a test-suite setted up for some value (class-instance). Now there are anothe value with the same properties, and I want it to be tested in the same test-suite. Workaround looks very ugly:
> 
> (deftestsuite percl-db-test (percl-test)
>   ((*db* (make-instance 'tst-mem-db)))
> 
> (addtest (percl-db-test) store ...)
> (addtest (percl-db-test) load ...)
> 
> ;.....
> 
> (deftestsuite percl-db-test (percl-test)
>   ((*db* (make-instance 'tst-sql-db)))
> 
> (addtest (percl-db-test) store ...)
> (addtest (percl-db-test) load ...)
> 
> Is there any way to do it smart?
> 
> Regards,
>  Necto.
> _______________________________________________
> lift-devel mailing list
> lift-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/lift-devel

--
Gary Warren King, metabang.com 
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM * gwking on twitter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/lift-devel/attachments/20120318/dd8972d2/attachment.html>


More information about the lift-devel mailing list