我在 NETBEANS 中使用 Symfony 功能测试。是否可以定义执行测试用例的顺序?
例如:我有“ UserTestCase ”案例用于测试用户注册,更改他们的个人资料等,以及“ ForumTestCase ”用于测试论坛帖子的创建等。我想在ForumTestCase之前运行UserTestCase。现在的顺序是根据文件名(F.. 在 U.. 之前)
我正在尝试测试我的控制器.在我试图测试update动作之前,一切都很好.
这是我的测试
require 'test_helper'
class BooksControllerTest < ActionController::TestCase
test "should not update a book without any parameter" do
assert_raises ActionController::ParameterMissing do
put :update, nil, session_dummy
end
end
end
Run Code Online (Sandbox Code Playgroud)
这是我的控制器
class BooksController < ApplicationController
(...)
def update
params = book_params
@book = Book.find(params[:id])
if @book.update(params)
redirect_to @book
else
render 'edit'
end
end
(...)
def book_params
params.require(:book).permit(:url, :title, :price_initial, :price_current, :isbn, :bought, :read, :author, :user_id)
end
end
Run Code Online (Sandbox Code Playgroud)
我的应用程序的书籍控制器的路线如下:
books GET /books(.:format) books#index
POST /books(.:format) books#create
new_book GET /books/new(.:format) books#new
edit_book …Run Code Online (Sandbox Code Playgroud) 该Symfony的测试文件并没有真正提区分功能测试和集成测试,但我的理解是,它们是不同的。
Symfony 文档描述了这样的功能测试:
虽然Ruby on Rails 文档是这样描述的:
Symfony 文档似乎在描述更类似于集成测试的东西。单击链接、填写表单、提交它们等。您正在测试所有这些不同的组件是否正确交互。在他们的示例测试用例中,他们基本上通过遍历网页来测试控制器的所有操作。
我很困惑为什么 Symfony 没有区分功能测试和集成测试。Symfony 社区中是否有人将测试与特定控制器操作隔离开来?我是不是想多了?
我使用testcafe测试框架-https: //devexpress.github.io/testcafe。
我写了以下代码:
const table = Selector('#table');
for(let i = 0; i < table.rows.length; i++){
for(let j = 0; j < table.columns.length; j++) {
let tdText = await table.rows[i].cells[j].textContent;
//another actions
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用testcafe获取表中所有单元格的文本?
javascript automated-tests web-testing functional-testing testcafe
我使用 mocha 进行 Node.js 功能测试。
我的测试中有几个文件。
如何在所有测试开始之前只运行一段代码一次?
例如,我可能必须在所有测试开始之前设置一个 docker 容器。用摩卡可以做到这一点吗?
该before钩子为每个测试文件运行 1 次。这不能满足我的需求。
假设 API 请求获取用户 ID、电子邮件地址和生日。示例 API 请求如下:
GET: /v1/users HTTP/1.1
Content-Type: application/json
Authorization: bearer {access_token}
Run Code Online (Sandbox Code Playgroud)
对于上述请求,响应如下:
{
"content": [
{
"id": 1,
"email": "random@random.com",
"birthday": "1990-01-01"
},
{
"id": 40,
"email": "random1@random1.com",
"birthday": "1990-18-10"
}
],
"last": false,
"total_elements": 2,
"total_pages": 1,
"sort": null,
"first": true,
"number_of_elements": 2,
"size": 20,
"number": 0
}
Run Code Online (Sandbox Code Playgroud)
现在,邮递员将进行什么测试以确保生日节点下的所有返回值都大于 1988-18-01?
我尝试了以下方法:
pm.test("Check birthday greater than 1988-18-01", () => {
for (i = 0; i < jsonData.content.length; i++) {
var a = '1988-18-01';
pm.expect(jsonData.content[i].birthday).to.be.above(a);
}
});
Run Code Online (Sandbox Code Playgroud)
但是邮递员说:“检查生日大于 …
我正在尝试使用以下方法访问由功能测试生成的探查器
$client->enableProfiler()
Run Code Online (Sandbox Code Playgroud)
并通过恢复令牌
$client->getProfile()->getToken()
Run Code Online (Sandbox Code Playgroud)
但是当我转到页面“/_profiler/{TOKEN}”时,我收到消息
未找到令牌 在数据库中未找到令牌“{TOKEN}”。
environment profiler unit-testing functional-testing symfony
在test_helper中:
class Logger
@@log = []
def self.info(message)
@@log.push(message)
end
def self.log
@@log
end
end
Run Code Online (Sandbox Code Playgroud)
但是在运行测试时,它似乎使用常规的Logger.
如何为Logger创建模拟?
Rails 3.0.7.
我有以下,
type Pos = (Int, Int)
Run Code Online (Sandbox Code Playgroud)
我想生成这种类型的随机值,但有一些限制(两者都必须是0-8)
我想做点什么
instance Arbitrary Pos where
arbitrary = do x <- choose(0,8)
y <- choose(0,8)
return (x,y)
Run Code Online (Sandbox Code Playgroud)
然后在我的测试中使用它来获得有效的职位.
这不会起作用bc我是别名(?)元组
我试过的其他方法是在我的测试中使用含义来说
prop_my_prop (x,y) = abs x < 9 && abs y < 9 ==> ...
Run Code Online (Sandbox Code Playgroud)
但我认为这很丑陋,理论上它可能会耗尽快速检查(运行超过1000次).
这是一项任务,所以我只想要一些指示来看待或如何处理这个,我不允许改变Pos.
testing haskell functional-programming functional-testing quickcheck
我遵循了本教程(使用 Azure DevOps 为 Python Flask 构建 DevOps CI/CD 管道)。有一个命令行任务来执行功能测试,我在运行它时遇到错误。
命令行任务脚本如下:
pip install selenium && pip install pytest && pytest Tests/functional_tests/ --webAppUrl=$(webAppUrl.AppServiceApplicationUrl) --junitxml=TestResults/test-results.xml
Run Code Online (Sandbox Code Playgroud)
这是用于功能测试的脚本:
import pytest
from selenium import webdriver
import unittest
import os
import sys
import pytest
import time
class FunctionalTests(unittest.TestCase):
def setUp(self):
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
self.driver = webdriver.Chrome(os.path.join(os.environ["ChromeWebDriver"], 'chromedriver.exe'), chrome_options=options)
self.driver.implicitly_wait(300)
def test_selenium(self):
webAppUrl = pytest.config.getoption('webAppUrl')
start_timestamp = time.time()
end_timestamp = start_timestamp + 60*10
while True:
try:
response = self.driver.get(webAppUrl)
title = self.driver.title
self.assertIn("Home Page …Run Code Online (Sandbox Code Playgroud) javascript ×3
symfony ×3
testing ×3
unit-testing ×2
azure ×1
azure-devops ×1
environment ×1
flask ×1
haskell ×1
minitest ×1
mocha.js ×1
mocking ×1
netbeans-7 ×1
node.js ×1
postman ×1
profiler ×1
pytest ×1
qa ×1
quickcheck ×1
testcafe ×1
web-testing ×1