Index: README.md |
diff --git a/README.md b/README.md |
index 30bcfcadbdb128d603ec37bd78f7926d011d759b..5a3b8c183879024e3046d2b7aeeba2faf857cb0d 100644 |
--- a/README.md |
+++ b/README.md |
@@ -9,8 +9,86 @@ Expect Tests is a test framework which: |
You can run the test suite with 'nosetests expect_tests/test' in the root |
directory. |
-## Fiddly details |
+## Quick user manual |
-If you have a package that you'd like to exclude from expect_tests' search, |
-simply define a variable `_expect_tests_stop_walk = True` in the package's |
-`__init__.py` and expect_tests won't search further in that directory tree. |
+### Writing tests |
+Tests are subclasses of unittests.TestCase only. expect_tests looks for tests in |
+files named like '*\_test.py'. The coverage information for file foo.py is only |
+collected from tests located in 'tests/foo\_test.py'. |
+ |
+### Invocation |
+The simplest expect_tests invocation is: |
+ |
+expect_tests (list|test|train) <path> |
+ |
+where <path> can point either to a Python (sub)package's directory, or to a |
+directory containing Python packages. In the latter case, all tests in all |
+packages in the directory will be considered. |
+ |
+ * list: just output the full list of tests on stdout |
+ * test: run the tests |
+ * train: run the test and update their expectations instead of checking |
+ against them. |
+ |
+### Filtering tests |
+It is possible to run an action on a subset of test instead of all of them. This |
+is achieved by appending a filter after the path specification: |
+ |
+expect_tests (list|test|train) <path>:<filter glob> |
+ |
+<filter glob> applies to the full test names, as output by 'list'. It does not |
+apply to the package path. |
+ |
+Example: Suppose you have the following structure: |
+ |
+ root/ |
+ root/package1 |
+ root/package1/__init__.py |
+ root/package1/foo.py |
+ root/package1/tests/__init__.py |
+ root/package1/tests/foo_test.py # contains test TestFoo.test\_feature |
+ root/package1/subpackage |
+ root/package1/subpackage/__init__.py |
+ root/package1/subpackage/subfoo.py |
+ root/package1/subpackage/tests/__init__.py |
+ root/package1/subpackage/tests/subfoo_test.py # contains TestSubFoo.test\_feature |
+ root/package2/... # with same structure as package1 |
+ |
+Then (supposing the current directory is the parent of 'root/') |
+ |
+ $ expect_tests list root |
+ package1.tests.foo_test.TestFoo.test_feature |
+ package1.subpackage.tests.subfoo_test.TestSubFoo.test_feature |
+ package2.tests.foo_test.TestFoo.test_feature |
+ package2.subpackage.tests.subfoo_test.TestSubFoo.test_feature |
+ |
+ $ expect_tests list root/package1 |
+ package1.tests.foo_test.TestFoo.test_feature |
+ package1.subpackage.tests.subfoo_test.TestSubFoo.test_feature |
+ |
+ $ expect_tests list 'root:package1*' # less efficient than root/package1 |
+ package1.tests.foo_test.TestFoo.test_feature |
+ package1.subpackage.tests.subfoo_test.TestSubFoo.test_feature |
+ |
+ $ expect_tests list 'root/package1:*TestSubFoo*' |
+ package1.subpackage.tests.subfoo_test.TestSubFoo.test_feature |
+ |
+ |
+### Fine-tuning and advanced topics |
+ |
+Having trouble debugging a test? You can use the 'debug' action instead of |
+'test' to get a debugging prompt when entering tests. That way you can step |
+through the code if necessary. |
+ |
+You can make expect_tests ignore a subpackage by adding a .expect\_tests.cfg |
+file in the directory containing the package, with the following content: |
+ |
+ [expect_tests] |
+ skip=packagetoignore1 |
+ packagetoignore2 |
+ |
+Some Python code, like the Appengine sdk, requires some special setup to be able |
+to work. In order to support that, you can create a .expect\_tests\_pretest.py |
+file in the directory containing the top-level package containing tests. This |
+code will be execfile'd just before any operation (list/run/train) in this |
+directory. |