Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 1.7 KB

README.md

File metadata and controls

39 lines (32 loc) · 1.7 KB

fntest

Used internally by both the test task of the lein-immutant plugin and Immutant's own integration tests, this library enables you to test against your application while deployed on WildFly or even run your tests within the deployed application itself. Here's an example:

    (ns your.test-code
      (:use clojure.test)
      (:require [clj-http.client :as http]
                [fntest.core     :as fnt]))
    
    ;;; Run Immutant and deploy our application
    (use-fixtures :once
      (compose-fixtures
        fnt/with-jboss
        (fnt/with-deployment "some-name" "/path/to/war-file/or/lein/project")))

    ;;; Run browser tests against the deployed app
    (deftest remote-http-test
      (let [result (http/get (format "http://localhost:%d/foo" (fnt/offset-port :http)))]
        (is (.contains (:body result) "Howdy!"))))
        
    ;;; Alternatively, deploy and run all tests in one shot, but be
    ;;; careful not to invoke test-in-container inside the container!
    (deftest run-all-tests-inside-immutant
      (is (fnt/test-in-container "some-name" "./" :dirs ["container"])))

Midje, Expectations and clojure.test tests are supported by fntest.core/test-in-container. Which tests are run depends on which testing library is found on the classpath. If Midje is present, then both Midje and clojure.test tests are run via the Midje test runner. If Midje is not found, but Expectations is present, then only the Expectations tests are run. If neither Midje nor Expectations is found, the standard clojure.test test runner is used.