Merge: doc: fixed some typos and other misc. corrections
[nit.git] / lib / popcorn / pop_tests.nit
index 1deaeab..9795b01 100644 (file)
 # 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)
@@ -68,7 +69,6 @@
 # See `examples/hello_world` for the complete example.
 module pop_tests
 
-import test_suite
 import popcorn
 import pthreads
 
@@ -79,9 +79,11 @@ redef class Sys
 
        # 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.
@@ -123,7 +125,6 @@ end
 
 # TestSuite for Popcorn blackbox testing.
 class TestPopcorn
-       super TestSuite
 
        # Host used to run App.
        var host: String = test_host
@@ -131,6 +132,11 @@ class TestPopcorn
        # 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)