วันเสาร์ที่ 14 เมษายน พ.ศ. 2561

Commit 6 Wordbucket : Ensuring Test Isolation

Assignment1 : Wordbucket GitHub Link

Commit 6 Wordbucket : Ensuring Test Isolation

Commits on Feb 26, 2018

- เปลี่ยน functional test ตาม Test-Driven Development with Python(Chapter 6) เพื่อเปลี่ยนไปใช้ LiveServerTestCase เพื่อจะผ่าน manage.py ของ django

เปลี่ยน unittest.TestCase เป็น LiveServerTestCase จึงสามารถใช้ self.live_server_url แทนกำหนดเป็น localhost:8000 ได้ทำให้ง่ายต่อการทดสอบเมื่อ deploy webapp. แล้ว

@@ -1,9 +1,9 @@
+from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
-import unittest
-class NewVisitorTest(unittest.TestCase):
+class NewVisitorTest(LiveServerTestCase):
def setUp(self):
self.browser = webdriver.Firefox()
@@ -19,7 +19,7 @@ def check_for_row_in_list_table(self, row_text):
def test_can_start_a_list_and_retrieve_it_later(self):
# Ann has heard about a cool new online word app. She goes
# to check out its homepage
- self.browser.get('http://localhost:8000')
+ self.browser.get(self.live_server_url)
# She notices the page title and header mention Word Bucket lists
self.assertIn('Word Bucket', self.browser.title)

ไม่มีความคิดเห็น:

แสดงความคิดเห็น