Writing your first Django app, part 5
https://docs.djangoproject.com/en/3.0/intro/tutorial05/
Github Tag: https://github.com/studroid/writing-your-fisrt-django-app/commits/Part-5-Finished
* 참고: 유튜브 라이브 스트리밍 하는 방법 - https://youtu.be/yF58bV_lVCo
참고 자료
Test Driven Development (TDD)
https://en.wikipedia.org/wiki/Test-driven_development
https://en.wikipedia.org/wiki/Test-driven_development
Shell(python manage.py shell)에서 View Test 할 때에는 setup_test_environment()를 먼저 호출해야 함
Shell에서 Client 테스팅 시 테스트 데이터베이스가 아닌 실제 데이터베이스 데이터를 가지고 테스트하게 됨
Note that this method does not setup a test database, so the following will be run against the existing database and the output may differ slightly depending on what questions you already created. You might get unexpected results if your
Note that this method does not setup a test database, so the following will be run against the existing database and the output may differ slightly depending on what questions you already created. You might get unexpected results if your
TIME_ZONE
in settings.py
isn’t correct.TestCase를 상속한 후 정의하는 테스트 함수들에서, 매 함수 실행 때마다 데이터베이스의 데이터들은 초기 상태에서 시작함(테스트 데이터베이스 리셋)
The database is reset for each test method, so the first question is no longer there, and so again the index shouldn’t have any questions in it.
The database is reset for each test method, so the first question is no longer there, and so again the index shouldn’t have any questions in it.
When testing, more is better
It might seem that our tests are growing out of control. At this rate there will soon be more code in our tests than in our application, and the repetition is unaesthetic, compared to the elegant conciseness of the rest of our code.
It doesn’t matter. Let them grow. For the most part, you can write a test once and then forget about it. It will continue performing its useful function as you continue to develop your program.
Selenium 등 브라우저 기반 자동화 테스트 프레임워크도 있고, 기타 다른 테스팅 도구들이 장고에서 많이 지원됨
For example, while our tests here have covered some of the internal logic of a model and the way our views publish information, you can use an “in-browser” framework such as Selenium to test the way your HTML actually renders in a browser. These tools allow you to check not just the behavior of your Django code, but also, for example, of your JavaScript. It’s quite something to see the tests launch a browser, and start interacting with your site, as if a human being were driving it! Django includes
For example, while our tests here have covered some of the internal logic of a model and the way our views publish information, you can use an “in-browser” framework such as Selenium to test the way your HTML actually renders in a browser. These tools allow you to check not just the behavior of your Django code, but also, for example, of your JavaScript. It’s quite something to see the tests launch a browser, and start interacting with your site, as if a human being were driving it! Django includes
LiveServerTestCase
to facilitate integration with tools like Selenium.코드 테스트 커비리지 확인하기
https://docs.djangoproject.com/en/3.0/topics/testing/advanced/#topics-testing-code-coverage
https://docs.djangoproject.com/en/3.0/topics/testing/advanced/#topics-testing-code-coverage
Advanced - Testing in Django (나중에 읽기)
https://docs.djangoproject.com/en/3.0/topics/testing/
https://docs.djangoproject.com/en/3.0/topics/testing/
Selenium - 나중에 해보기
For example, while our tests here have covered some of the internal logic of a model and the way our views publish information, you can use an “in-browser” framework such as Selenium to test the way your HTML actually renders in a browser. These tools allow you to check not just the behavior of your Django code, but also, for example, of your JavaScript. It’s quite something to see the tests launch a browser, and start interacting with your site, as if a human being were driving it! Django includes
For example, while our tests here have covered some of the internal logic of a model and the way our views publish information, you can use an “in-browser” framework such as Selenium to test the way your HTML actually renders in a browser. These tools allow you to check not just the behavior of your Django code, but also, for example, of your JavaScript. It’s quite something to see the tests launch a browser, and start interacting with your site, as if a human being were driving it! Django includes
LiveServerTestCase
to facilitate integration with tools like Selenium.