Django
django TDD
jwstory.com
2022. 2. 19. 21:56
반응형
- Test 실행 방법
- python manage.py test
- django의 각 app에는 tests.py가 있고 거기에 Test Source를 작성하면 됩니다.
class TestView(TestCase): def test_post_list(self): self.assertEqual(2, 3)
- 결과
- 2는 3이 아니므로 Test는 Fail이 됩니다.
$ python manage.py test
Found 1 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
F
======================================================================
FAIL: test_post_list (blog.tests.TestView)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/blog/tests.py", line 6, in test_post_list
self.assertEqual(2, 3)
AssertionError: 2 != 3
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (failures=1)
Destroying test database for alias 'default'...
반응형