Re: [racket-users] Setup/teardown for unit testing

2016-03-09 Thread Matthias Felleisen
On Mar 9, 2016, at 11:06 AM, Sam Tobin-Hochstadt wrote: > I think having a built-in way to do something like this would be a > good thing, rather than having everyone write their own abstraction > for this. One way we've avoided divergence in the Racket community > despite Racket's flexibility i

Re: [racket-users] Setup/teardown for unit testing

2016-03-09 Thread Ryan Culpepper
I think it would be more (Racket-)idiomatic to make account a parameter (as in make-parameter) and have something that can update the parameter around a test case. Here is my preferred extension, by example: (define account (make-parameter #f)) (define (call/open-bank proc) (parameterize ((a

Re: [racket-users] Setup/teardown for unit testing

2016-03-09 Thread Brian Adkins
If you're going to add something, please don't do #1 :) That's how it's done in Ruby, but it's an OO, stateful platform, so it fits. The only other way I've seen recently is the Elixir version ( http://elixir-lang.org/docs/stable/ex_unit/ExUnit.Case.html

Re: [racket-users] Setup/teardown for unit testing

2016-03-09 Thread Brian Adkins
I think you're right. Coming from a Ruby perspective, the lack of a setup facility seemed like a glaring omission at first glance, but I do strongly favor orthogonality and dislike bloat - thanks for the macro example. > On Mar 9, 2016, at 10:53 AM, Jay McCarthy wrote: > > I looked at the gist

Re: [racket-users] Setup/teardown for unit testing

2016-03-09 Thread Sam Tobin-Hochstadt
I think having a built-in way to do something like this would be a good thing, rather than having everyone write their own abstraction for this. One way we've avoided divergence in the Racket community despite Racket's flexibility is by building in the right abstractions in core libraries. But I sh

Re: [racket-users] Setup/teardown for unit testing

2016-03-09 Thread Jay McCarthy
I looked at the gist you posted. I don't think it is plausible for us to add something like that to the test code, because you're imagining splicing the test body after the before exprs (because in your example, the before binds an identifier.) I really think you just want a slightly different tes

Re: [racket-users] Setup/teardown for unit testing

2016-03-08 Thread WarGrey Gyoudmon Ju
Hi, Brina. This is my README of how I use RackUnit in my project. http://gyoudmon.org/~wargrey:wisemon/readme_rkt.html#%28elem._%28chunk._~3ctestsuite~3a._building._the._baby._digimon~3e~3a1%29%29 (test-suite

Re: [racket-users] Setup/teardown for unit testing

2016-03-08 Thread Brian Adkins
Not exactly. I'm looking for a way to run a function before *each*, of possibly many, test-cases. The test-suite #:before only runs once before running all the test-cases. Although my gist: https://gist.github.com/lojic/db7016fb95b1c05e4ade only has a few test-cases, if there were many, the red

Re: [racket-users] Setup/teardown for unit testing

2016-03-08 Thread Matthias Felleisen
Are you looking for something like this: #lang racket (require rackunit rackunit/text-ui) (define my-database #f) (define my-first-test-suite (test-suite "An example suite" #:before (lambda () (set! my-database '(a b c)) (displayln `(Before ,my-database))) #:after (lambda () (set

Re: [racket-users] Setup/teardown for unit testing

2016-03-08 Thread Robby Findler
One reason to want that kind of functionality is to maintain good source location information on test failures (which helper functions don't). Robby On Tuesday, March 8, 2016, Brian Adkins wrote: > Jay: > > Here's a gist: https://gist.github.com/lojic/db7016fb95b1c05e4ade > > without.rkt is how

Re: [racket-users] Setup/teardown for unit testing

2016-03-08 Thread Brian Adkins
Jay: Here's a gist: https://gist.github.com/lojic/db7016fb95b1c05e4ade without.rkt is how I coded it up and with.rkt is how I'd like to be able to code it. I agree that it's trivial to add, but for something as common as "setup" and "teardown" for unit testing, there may be an advantage to hav

Re: [racket-users] Setup/teardown for unit testing

2016-03-08 Thread Jay McCarthy
Hi Brian, Can you explain what you want to write? Just imagine that the feature was already there... what do you want? I think of Rackunit as a way of writing checks, so if I wanted to do what you're talking about, then I'd define the macro/function that you don't want to. In other words, with Ra

[racket-users] Setup/teardown for unit testing

2016-03-08 Thread Brian Adkins
Does RackUnit provide a facility similar to the setup & teardown functions of other unit testing frameworks? In other words, I'd like to execute some code before each test w/o coding each test to call a setup function or having to create my own macro given how common this is. As far as I can te