1506689042-practice
Ardian Jati Permadi - 1506689042 - PMPL A
site : http://pmpl-ardian.herokuapp.com/
Exercise 3
Test isolation dilakukan dengan menggabungkan functional test kedalam unit test django. Test isolation ini menggunakan class LiveServerTestCase, dimana class ini akan me-create database baru yang digunakan untuk test sehingga bisa secara aman di-reset dan tidak mempengaruhi database yang asli.
Perbedaan code
Sebelum
functional_tests.py
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import unittest
class NewVisitorTest(unittest.TestCase):
def setUp(self):
[...]
def test_can_start_a_list_and_retrieve_it_later(self):
# Edith has heard about a cool new online to-do app. She goes
# to check out its homepage
self.browser.get('http://localhost:8000')
[...]
Sesudah
functional_tests/tests.py
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import WebDriverException
import time
MAX_WAIT = 10
class NewVisitorTest(LiveServerTestCase):
def setUp(self):
[...]
def test_can_start_a_list_and_retrieve_it_later(self):
# Edith has heard about a cool new online to-do app. She goes
# to check out its homepage
self.browser.get(self.live_server_url)
[...]