0

別の django コマンドでセレン テストを実行するのに問題があります。デフォルトの「test」コマンドは「tests」フォルダーを調べて、unittests を正常に実行します。問題は、フォルダー「seleniumtests」を作成し、そこにテストファイルを配置して、コマンド「test_selenium」で実行したいことです。そして、このコマンドでデフォルトのdjango「test」と同じことを別のディレクトリで実行したい。
selenium を使用した tests.py:

from django_liveserver.testcases import LiveServerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver


class MySeleniumTests(LiveServerTestCase):
#    fixtures = ['test-data.json']

@classmethod
def setUpClass(cls):
    cls.selenium = WebDriver()
    super(MySeleniumTests, cls).setUpClass()

@classmethod
def tearDownClass(cls):
    super(MySeleniumTests, cls).tearDownClass()
    cls.selenium.quit()

def test_admin(self):
    self.selenium.get(self.live_server_url +'/admin/')
    self.assertIn("Django", self.selenium.title)
4

1 に答える 1

1

テストをフォルダーに入れる方法については、次のチュートリアルに従ってください:http ://www.pioverpi.net/2010/03/10/organizing-django-tests-into-folders/

一般に:

from [Project Name].[App Name].tests.[filename] import *  
from [Project Name].[App Name].seleniumtests.[selenium] import *  

#starts the test suite  
__test__= {  
           'your_django_tests': [filename],
            'selenium': [selenium],
           }  
于 2012-09-03T06:45:43.040 に答える