Skip to content

Comments

Fix the order of expected and actual in handler_test.clj template#30

Open
paasar wants to merge 1 commit intoweavejester:masterfrom
paasar:fix/expected-actual
Open

Fix the order of expected and actual in handler_test.clj template#30
paasar wants to merge 1 commit intoweavejester:masterfrom
paasar:fix/expected-actual

Conversation

@paasar
Copy link

@paasar paasar commented Nov 29, 2019

Expected and actual values were mixed in the handler_test.clj template.

To demonstrate this, after creating a new compojure project I changed the expected value for the response body:

$ cat test/expected_actual/handler_test.clj
(ns expected-actual.handler-test
  (:require [clojure.test :refer :all]
            [ring.mock.request :as mock]
            [expected-actual.handler :refer :all]))

(deftest test-app
  (testing "main route"
    (let [response (app (mock/request :get "/"))]
      (is (= (:status response) 200))
      (is (= (:body response) "EXPECTED Hello World"))))

  (testing "not-found route"
    (let [response (app (mock/request :get "/invalid"))]
      (is (= (:status response) 404)))))

And running tests gives you this result, which is obviously wrong:

$ lein test

lein test expected-actual.handler-test

lein test :only expected-actual.handler-test/test-app

FAIL in (test-app) (handler_test.clj:10)
main route
expected: "Hello World"
  actual: "EXPECTED Hello World"
    diff: - "Hello World"
          + "EXPECTED Hello World"

Ran 1 tests containing 3 assertions.
1 failures, 0 errors.
Tests failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant