Hi all, I have gone through https://docs.racket-lang.org/web-server/test.html to finally stop manually checking whether I didn't introduce new bugs in one of my servlets. I think that I have figured out most of the wrinkles for this, except one.
I run my tests via `raco test server.rkt`, and server.rkt has the following structure: (require web-server/test web-server/servlet ...) (define (start request) (define-values (top-dispatch top-urls) (dispatch-rules [("") home] [("login") #:method (or "post" "get") log-in] [("mp") #:method (or "post" "get") mp] ... )) (top-dispatch request)) (module+ main (serve/servlet start ...)) (module+ test (define (test-start-servlet) (define experiment-servlet-tester (make-servlet-tester start)) ; Test all the routes. This only tests that they don't raise exceptions (define routes (list '() ; Tests "/" '("/login") '("/mp") )) (for ([route routes]) (check-not-exn (λ () (apply experiment-servlet-tester route)))) (define matrix-servlet-tester (make-servlet-tester (λ (req) (matrix req #:h (hash 'mturk-id "TESTER"))))) (matrix-servlet-tester) (displayln "All pages render without exception")) (test-start-servlet)) The meat of what is going on is in the test module at the end. I create a servlet-tester for the start servlet, which uses a dispatcher, and since I have a bunch of routes I go through them in a for-loop. However, even though the "/login" route throws an exception, the (test-start-servlet) code is happily marching on, checks the "/mp" route, and then prints "All pages render without exception". And raco test tells me that all the tests are passing! How do I know that there is an exn? Because it prints the following right before the test results: Servlet (@ /372d34a3-df04-478f-8d84-94fb212725c2) exception: >: contract violation expected: real? given: #<sql-null> argument position: 1st other arguments...: 0 So, what is going on here? Clearly test-servet does some exception catching in between, yet it still prints it to the screen? How can I test for this, since I want to know how many and which pages blow up? Also, when I want to test matrix at the end, I have to pass it an extra argument. Is it the right way of passing in the argument by defining a new servlet where I set the argument to some fixed value, as I do above via: (define matrix-servlet-tester (make-servlet-tester (λ (req) (matrix req #:h (hash 'mturk-id "TESTER"))))) It seems to work, but I am wondering if I can pass arguments directly to `make-servlet-tester`, but I couldn't figure out how. Thanks, Marc -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/a7ae5893-5bdd-4b3f-924a-42e4936d2a68%40googlegroups.com.