标签: functional-testing

assert_no_template

我在想,如果我们是否有类似assert_no_template的的对面assert_template.

我试图测试的是实际渲染中没有使用具体模板.

ruby-on-rails functional-testing

4
推荐指数
2
解决办法
869
查看次数

如何在Rails 3中的功能测试中使用polymorphic_path

我正在尝试polymorphic_path在Rails 3中使用功能测试.

起初我会得到

NoMethodError: undefined method `polymorphic_path' for #<ArticlesControllerTest:0x492f17c>
Run Code Online (Sandbox Code Playgroud)

然后我补充道

include Rails.application.routes.url_helpers
Run Code Online (Sandbox Code Playgroud)

undefined method error停止了,但现在常规路径,如article_path(article)例如停止工作:

NameError: undefined local variable or method `default_url_options' for #<ArticlesControllerTest:0x33ccbe0>
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/routing/url_for.rb:102:in `url_options'
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/routing/url_for.rb:131:in `url_for'
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:195:in `article_path'
Run Code Online (Sandbox Code Playgroud)

我曾经能够通过包含在Rails 2中正常使用polymorphic_path

include ActionController::UrlWriter
Run Code Online (Sandbox Code Playgroud)

如何在Rails 3中使用它?

ruby ruby-on-rails functional-testing ruby-on-rails-3 rails-3-upgrade

4
推荐指数
1
解决办法
2561
查看次数

Rails:单个功能测试中的多个get请求

我想在相同的测试中对一些获取请求进行分组,但是我得到了不稳定的行为.我有以下两个测试:

test 'index for local seller (same site)' do
  seller = FactoryGirl.create :seller, business_site: @open_or.business_site
  get :index, nil, {user_id: seller.to_param }
  assert_select "table#order_requests tr##{@controller.view_context.dom_id @open_or}"
end
test 'index for local seller (different site)' do
  seller = FactoryGirl.create :seller_local
  get :index, nil, {user_id: seller.to_param }
  assert_select "table#order_requests tr##{@controller.view_context.dom_id @open_or}", false
end
Run Code Online (Sandbox Code Playgroud)

我希望在一次测试中合并,但如果我这样做,第二个断言将错误地失败(预期正好0个元素匹配"table#order_requests tr#order_request_1000244799",找到1.).我真的不明白为什么?第二次'get'调用可能无法正常重置某些内容.我想方设法"重置"请求但没有成功.

相关:在rails集成规范中向同一个控制器发出两个请求

ruby-on-rails functional-testing

4
推荐指数
1
解决办法
2164
查看次数

编写Django RESTful API的功能测试

我正在尝试为使用Django REST Framework编写的REST API编写一些功能测试.然而,它并不是特定于该框架,因为它主要是一般的Django.

这就是我想要做的

  1. setUp在测试类的方法中创建用户
  2. 使用测试客户端从API请求用户令牌

tests.py

from django.test import LiveServerTestCase

from django.contrib.auth.models import User
from django.test.client import Client
from rest_framework.authtoken.models import Token

class TokenAuthentication(LiveServerTestCase):
    def setUp(self):
        user = User.objects.create(username='foo', password='password', email="foo@example.com")
        user.save()
        self.c = Client()

    def test_get_auth_token(self):
        user = User.objects.get(username="foo")
        print user # this outputs foo
        print Token.objects.get(user_id = user.pk) # this outputs a normal looking token
        response = self.c.post("/api-token-auth/", {'username': 'foo', 'password': 'password'})
        print response.status_code # this outputs 400
        self.assertEqual(response.status_code, 200, "User couldn't log in")
Run Code Online (Sandbox Code Playgroud)

当我运行测试时,它返回状态400而不是200,因此用户未经过身份验证.如果我输入已经在数据库中的用户的凭据,它会通过.所以我假设在测试类中创建的记录只能在它自己的方法中访问,这可能是因为它是为单元测试而设计的.但是我使用数据库中的数据来执行测试,如果数据发生变化,它将失败. …

django functional-testing django-testing django-rest-framework

4
推荐指数
1
解决办法
3452
查看次数

Scala:找到类型不匹配,需要单位:布尔值

我一直试图运行这段代码,但不知何故已经出现'单位不匹配,布尔预期错误'.我已经在Stackoverflow上遇到了各种问题,但没有找到任何具体的问题来回答我的问题.

  def balance(chars: List[Char]): Boolean =
  {
    var i = 0;
    var j = 0;

    if (Count(i, j) == 0){
      true
    }
    else{
      false
    }

    def Count(count: Int, Pos: Int): Int = 
    {
            if (Pos == chars.length)
            {
                count
            }
            else
            {
                if (chars(Pos) == '(')
                {
                    Count(count + 1, Pos + 1);
                }
                else
                {
                    Count(count - 1, Pos + 1);
                }
            }
    }     
  } 
Run Code Online (Sandbox Code Playgroud)

scala functional-testing

4
推荐指数
1
解决办法
3384
查看次数

ServiceStack AppHostHttpListenerBase无法连接到远程服务器

我正在我的应用程序上进行一些功能测试,我想我已经非常接近了.我的问题是,当我运行第一次测试时,我得到了错误.

无法连接到远程服务器.

预期:好的
但是:0

我可以确认,如果我在断言上设置断点,然后尝试BaseUrl在我的浏览器中点击,则找不到它.

这是我的考试.

[Test]
public void MyTestTest ()
{
    var client = new RestClient( ServiceTestAppHostBase.BaseUrl );
    // client.Authenticator = new HttpBasicAuthenticator( NUnitTestLoginName, NUnitTestLoginPassword );
    var request = new RestRequest( "/users/", Method.GET );
    request.RequestFormat = DataFormat.Json;
    var response = client.Execute( request );

    // do assertions on the response object now
    Assert.That( response.StatusCode, Is.EqualTo( HttpStatusCode.OK ) );
}
Run Code Online (Sandbox Code Playgroud)

AppServerTestSetup这个样子的

[SetUpFixture]
public class AppServerTestSetup
{
    ServiceTestAppHostBase _appHost;

    [SetUp]
    public void SetUp()
    {
        _appHost = new ServiceTestAppHostBase(); …
Run Code Online (Sandbox Code Playgroud)

c# functional-testing servicestack

4
推荐指数
1
解决办法
730
查看次数

如何测试Meteor 1.0以来的Meteor包?

根据我的理解,有两个主要的软件包可以帮助测试软件包--TinyTest和Velocity,后者成为官方Meteor测试框架.

6月份Meteor的DevShop开始,Velocity团队表示Velocity可以和TinyTest一起运行,但是我不明白这两个软件包提供的功能有什么不同,一个(TinyTest)是多余的?

TinyTest仅用于单元测试吗?如果我想进行集成测试,功能测试,我是否需要转向Velocity及其支持的框架?还是别的什么完全不同?有一个比较表,但它有点过时了.

unit-testing functional-testing meteor meteor-velocity tinytest

4
推荐指数
1
解决办法
1489
查看次数

在功能测试中使用ajax提交表单

我正在为项目的题字部分创建功能测试,如果表单需要进入ajax请求,我需要知道如何测试它,否则服务器将始终返回空的题字表单.

看起来提交方法没有采用一个参数来指定它是否是一个不像请求方法的请求的ajax - > http://api.symfony.com/2.3/Symfony/Component/HttpKernel/Client.html#method_submit

谢谢

UPDATE1

////////////////////////////////////////////////
// My functional test looks exactly like this //
////////////////////////////////////////////////
$form = $buttonCrawlerNode->form(array(
    'name'              => 'Fabien',
    'my_form[subject]'  => 'Symfony rocks!',
));
// There is no way here I can tell client to submit using ajax!!!!
$client->submit($form);

// Why can't we tell client to submit using ajax???
// Like we do here in the request méthod
$client->request(
    'GET',
    '/post/hello-world',
    array(),
    array(),
    array('HTTP_X-Requested-With' => 'XMLHttpRequest')
);
Run Code Online (Sandbox Code Playgroud)

php ajax phpunit functional-testing symfony

4
推荐指数
1
解决办法
1910
查看次数

UI/GUI测试,功能测试和E2E测试有什么区别?

我会说三者都是一样的,但我想知道它们之间是否存在细微差别.最后,我认为您正在测试所有这些用户场景.

functional-testing gui-testing e2e-testing

4
推荐指数
1
解决办法
8656
查看次数

在所有Jest测试中重用相同的Puppeteer实例

问题

我正在用Jest + Puppeteer取代CasperJS.将所有内容放在一个文件中效果很好:

beforeAll(async () => {
  // get `page` and `browser` instances from puppeteer
});

describe('Test A', () => {
   // testing
});

describe('Test B', () => {
   // testing
});

afterAll(async () => {
 // close the browser
});
Run Code Online (Sandbox Code Playgroud)

现在,我真的不想将所有内容保存在一个文件中.维护更难以运行部分测试(例如,只是'测试A').

我试过的

我查看了Jest文档并阅读了有关setupScript的内容.它会很完美,但它会在每个测试文件之前运行.我不想要这个,因为puppeteer设置需要花费很多时间.无论我运行多少个测试文件,我都希望重复使用相同的浏览器实例并只支付一次设置成本.

所以,我想到了:

// setup puppeteer
await require('testA')(page, browser, config);
await require('testB')(page, browser, config);
// cleanup
Run Code Online (Sandbox Code Playgroud)

这解决了模块化问题,重用了相同的浏览器实例,但不允许我单独运行测试.

最后,我偶然发现了创建自定义testEnviroment的可能性.这听起来很棒但是没有很好的文档记录,所以我甚至不确定每个测试文件是创建env实例,还是每次运行Jest.稳定的API也是一个缺少一种setup方法,我可以设置puppeteer(我必须在构造函数中执行,不能是异步).

我为什么这么问

由于我是Jest的新手,我可能会遗漏一些明显的东西.在我深入研究之前,我会问这里.

functional-testing jestjs puppeteer

4
推荐指数
1
解决办法
2025
查看次数