• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
夜码人
            管理     

marionette初识三----Mn Python测试

1. 在FireFox中Marionette 是构建的远程协议的代号,也是用于自动化用户界面测试的功能性测试框架的名称。

2. 树内测试框架支持用 Python 编写的测试,使用 Python 的 unittest 库。 测试用例编写为 MarionetteTestCase 的子类,子测试属于名称以 test_ 开头的实例方法。

3. 还可以另外定义 setUp 和 tearDown 实例方法来执行子测试之前和之后的代码,以及定义setUpClass/tearDownClass 用于父测试

4.测试结构如下:

from marionette_test import MarionetteTestCase

class TestSomething(MarionetteTestCase):
    def setUp(self):
        # code to execute before any tests are run
        MarionetteTestCase.setUp(self)

    def test_foo(self):
        # run test for 'foo'

    def test_bar(self):
        # run test for 'bar'

    def tearDown(self):
        # code to execute after all tests are run
        MarionetteTestCase.tearDown(self)

5. 以下是由unittest提供的断言测试:

from marionette_test import MarionetteTestCase

class TestSomething(MarionetteTestCase):
    def test_foo(self):
        self.assertEqual(9, 3 * 3, '3 x 3 should be 9')
        self.assertTrue(type(2) == int, '2 should be an integer')

 

posted @ 2021-11-03 10:04  夜码人  阅读(173)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3