Github user eiri commented on the pull request:

    https://github.com/apache/couchdb-chttpd/pull/106#issuecomment-196325193
  
    Ok, I'll try to explain again. Fixtures, i.e. the test functions that end 
with _, take a list of _callbacks_. Here we are providing this list of 
callbacks in form of `fun before_request_match/0`, `fun 
before_request_no_match/0,` and so on. Fixture does not execute them 
immediately, but execute `setup/0` first and then starting to call them 
one-by-one. Each of those callbacks has to be a test object, i.e. has to either 
return result, anything, really, or throw an exception.
    
    Macros family ?_assert exists to simplify this task, i.e. you can pass into 
your fixture a list of `[?_assert(true), ?_assertEqual(a, a)]` and as a result 
get a list `[{?LINE, fun() -> ?assert(true) end}, {?LINE, fun() -> 
?assertEqual(a, a)}]` In other words ?_assert is test object generator, it 
creates the functions that, been called, either return or crash because this is 
what ?assert.. macros does.
    
    Here we already passing in a list of callbacks in form of `fun 
function/arity`. Each of those function has to be a test object, i.e. do an 
assertion when called. But they are instead calling test object generators in 
form of ?_assert and because this macros is not failing by itself, but just 
generate tuples of {?LINE, callback}, the tests are passing.
    
    To get this work properly each of the callbacks either has to call ?assert 
to do the assertion or instead of passing them as callbacks they need to be 
called in the list, i.e. `[before_request_match(), 
before_request_no_match()...]`. Then they'll propagate the list with 
?_assert... generators _before_ fixture execution and the generated assertions 
will be executed _during_ the test after setup call.
    
    I hope it makes sense now...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to