# Here we use `curl` to access some URI on the app.
#
# ~~~nitish
-# module test_example_hello is test_suite
+# module test_example_hello is test
#
# import pop_tests
# import example_hello
#
# class TestExampleHello
# super TestPopcorn
+# test
#
-# fun test_example_hello do
+# fun example_hello is test do
# var app = new App
# app.use("/", new HelloHandler)
# run_test(app)
# See `examples/hello_world` for the complete example.
module pop_tests
-import test_suite
import popcorn
import pthreads
# Return a new port for each instance
fun test_port: Int do
- srand
- return 10000+20000.rand
+ return testing_id % 20000 + 10000
end
+
+ # Nitdoc testing ID
+ fun testing_id: Int do return "NIT_TESTING_ID".environ.to_i
end
# Thread running the App to test.
# TestSuite for Popcorn blackbox testing.
class TestPopcorn
- super TestSuite
# Host used to run App.
var host: String = test_host
# Port used to run App.
var port: Int = test_port
+ # Directory of the current test suite
+ #
+ # Useful when your tested app need to load some external files.
+ var test_path: String = "NIT_TESTING_PATH".environ.dirname
+
# Run the test suite on the App.
fun run_test(app: App) do
var server = new AppThread(host, port, app)