Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
14424 Lượt xem

I wish all of you a happy new year! I want to write more unit tests in the new year, but how to handle it more easily? I found out to run tests while updating a module via --test-enable and --stop-after-init command line parameters. I have also read about --test-file parameter, but it does not work. This parameter is also not described in the docs.

How would you do TDD (test driven development)? In order to do that you have to be able to run tests quickly. Requiring to test the whole module with all its dependencies makes it impractical to write tests frequently. How to run a single unit test case?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

My solution so far:

python ./odoo.py -i module_to_test --log-level=test -d minimal_database --test-enable --stop-after-init

This is pretty common advice

However, the solution seems to be not to use the --test-file parameter, since this unexpectedly runs all tests of all dependent modules and does whatever else, making it too long to execute.

Another part of the solution is to use a minimal database where just the module to be tested plus its dependencies of course is installed.

Now the above command takes only several seconds to execute at my machine even if the tested code uses objects from dependent modules. If only I could prevent the module to make an update each time while running the tests in order to make it even faster and more efficient ...

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 5 22
19991
2
thg 6 20
6600
1
thg 5 20
3275
0
thg 11 19
4363
1
thg 11 19
6745