- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Selenium 框架中使用 TestNG 时,setUp 方法相对复杂。它可能会破坏多个点,我想将其拆分为单独的步骤。
理想情况下它看起来像这样:
// Does some DB stuff, logs some messages
@BeforeMethod(alwaysRun = true)
preTestCase
// Instantiates and opens up Selenium
@BeforeMethod(dependsOnMethods = {"preTestCase"})
seleniumSetup
// Closes Selenium only if it was properly setup
@AfterMethod(dependsOnMethods = {"seleniumSetup"})
seleniumTearDown
// All other test case teardown, error logging
@AfterMethod(alwaysRun=true)
postTestCase
我想避免的是由于数据库问题导致 preTestCase 失败,然后由于 seleniumTearDown 试图关闭不存在的实例而导致二次失败。在这种情况下,只应运行 postTestCase。我收到此错误:不允许 seleniumTearDown() 依赖于 public void seleniumSetUp(org.testng.ITestContext)。这是不允许的/糟糕的设计吗?如何在两个 tearDown 方法之间强制执行运行顺序,以便 postTestCase() 始终最后运行,而不管 seleniumTearDown 是否运行?
最佳答案
您的模型看起来有点虚,设置和拆卸应该不会失败。尽管他们可能会空手而归。如; “尝试建立数据库连接,但不可用,所以什么都不做”然后在拆除时,您应该在尝试关闭连接之前检查它们是否是连接。
否则,如果您想维护当前的模型,您可以使用某种手动检查而不是注释( boolean 值或单例类都可以)。
In Setup:
if(dbGetConnected()) {
....
} else {
dbisntconnected = true;
}
In tearDown:
if(!dbisntconnected) {
dbClose();
}
关于java - TestNG 中的多级设置/拆卸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3971487/
我正在测试一个类,有很多测试方法。但是,每种方法都有一个独特的上下文。然后我编写如下代码: class TestSomeClass(unittest.TestCase): def test_a
我有一些机器人测试用例在目录中分开。目录层次结构是: ParentTestDirectory |__ ChidTestDirectoryOne |__ TestOne.robo
是否有在测试场景开始/结束时触发的函数? setUp 和 tearDown 函数在每次测试之前/之后触发。 我通常想要这个: class TestSequenceFunctions(unittest.
我有一个商店,里面有元素。每个项目要么是一个组件(它是原子的),要么是由各种组件(但绝不是 2 个或更多相同组件)组成的产品。 现在,当我想从商店取货时,有多种情况: 商店包含必要数量的产品。 商店包
在我的 Selenium 框架中使用 TestNG 时,setUp 方法相对复杂。它可能会破坏多个点,我想将其拆分为单独的步骤。 理想情况下它看起来像这样: // Does some DB stuff
有人以前见过这个并且知道它的含义吗? 14:13:43 PhantomJS 1.9.8 (Linux) ERROR 14:13:43 Error: Cannot have setup/teardo
是否可以以编程方式创建/拆除 Spring 集成 channel ,而不是在 Spring 配置中静态声明它们? 我的情况是这样的: 我有一个需要推送通知的 web 应用程序,所以我使用了长轮询。那些
setUp 和 teardown(前置条件和后置条件设置)是否由名称 setUp() 和 teardown()< 标识 或 @Before 和 @After? 换句话说,在 JUnit 中是否可以有一
我目前正在重构代码,让原始指针使用智能指针,同时也在测试这个类,但遇到智能指针被过早删除的问题 这是一个例子: class SomeObjectType { public: void init(
使用 Apple 的 EADemo 作为基础,我试图了解背景对 EAAccessories 的影响。 当我收到 connectNotification 时,我会获取附件、检查协议(protocol)并
所以,我知道 gtest 有“字面上”的固定装置,但是构造函数/析构函数和设置/拆卸函数将在每个测试之后而不是在整个测试集之后执行夹具。 我能想到解决这个问题的方法,但是是否有一些我没有找到的内置支持
这个问题是关于单元测试框架的xUnit.net . 我需要在执行任何测试之前运行一些代码,并在所有测试完成后运行一些代码。我认为应该有某种属性或标记接口(interface)来指示全局初始化和终止代码
问题 我设置了一个简单的测试,比如 import pytest import pathlib @pytest.fixture def some_resource(): testdir = pa
我有一堆端到端的仪器测试(依赖于 Espresso)启动我们的启动器 Activity ,然后在我们的应用程序中导航(最终创建几个 Activity )。在每个 测试结束时,我们的@After 注释拆
我在 test_helper 中有以下代码 require "minitest/spec" require "minitest/autorun" require "database_cleaner"
我们的 pytest 环境有很多固定装置(主要是 scope='function' 和 scope='module'),它们正在执行以下形式的操作: @pytest.yield_fixture(sco
Pytest has 设置和拆卸 模块、类、方法的 Hook 。 我想在设置中(在测试 session 开始之前)创建我的自定义测试环境,并在所有测试完成后进行清理。换句话说,我如何使用像 setup
我正在尝试使用dbunit来测试系统的数据库。由于可以使用相同的数据集测试多个测试用例,因此我想为所有测试用例初始化一次数据集。但我也使用spring的@AutoWire来初始化那些数据库连接参数。
我有不同的测试文件夹(包)。我想为特定包(文件夹)设置和拆卸一些数据。 问题是 set_up() 在运行该文件夹的测试用例之前执行,但在运行所有测试用例之后,tear_down 没有执行。它也在运行其
我正在使用 Specs2 和使用 Scala 2.10.2(运行 Java 1.7.0_51)构建的 play 2.2.1。我一直在阅读有关如何使用 Specs2 进行设置/拆卸的信息。我已经看到使用
我是一名优秀的程序员,十分优秀!