草庐IT

TESTNG_TEST_TIMEOUT

全部标签

ruby-on-rails - rails 4 : How to reset test database?

我在使用Rails4并注意到我的一些RSpec测试失败了,因为我的一些测试重构使用了前置过滤器(大概是因为事务)。这篇文章描述了一个类似的问题:railstestdatabasenotclearingaftersomeruns代替使用DatabaseCleanergem,是否有清除测试数据库的rake命令?我相信rakedb:test:prepare在Rails4中被弃用了。此外,如果在交易之前,如`post:create,user:Fabricate.attributes_for(:user)`是持久性的,是否有另一种重构方式来避免手动清除测试数据库的需要?

ruby-on-rails - 如何在测试环境运行Rails控制台并加载test_helper.rb?

背景:我在使用Thoughtbot的“工厂女孩”gem时遇到了一些问题,该gem用于创建要在单元测试和其他测试中使用的对象。我想转到控制台并运行不同的FactoryGirl调用以检查发生了什么。例如,我想去那里做...>>Factory(:user).inspect我知道您可以在不同的环境中运行控制台...$脚本/控制台RAILS_ENV=test但是当我这样做时,工厂类不可用。看起来好像test_helper.rb没有加载。我尝试了各种require调用,包括一个带有到test_helper.rb的绝对路径的调用,但它们的失败与此类似:$script/consoleRAILS_ENV

ruby-on-rails - 什么是 rake db :test:prepare actually do?

我正在观看Rails教程视频,但我无法弄清楚db:test:prepare命令的实际作用。有人可以提供解释吗? 最佳答案 Therakedb:migrateaboverunsanypendingmigrationsonthedevelopmentenvironmentandupdatesdb/schema.rb.Therakedb:test:loadrecreatesthetestdatabasefromthecurrentdb/schema.rb.Onsubsequentattempts,itisagoodideatofirstr

javascript - 类型错误 : parsed is undefined on angularjs service unit test

我正在尝试对使用$http的服务进行单元测试。我正在使用Jasmine,但我一直收到此错误:TypeError:parsedisundefinedinangular.js(line13737)这是我的服务的样子:angular.module('myapp.services',[]).factory('inviteService',['$rootScope','$http',function($rootScope,$http){varinviteService={token:'',getInvite:function(callback,errorCallback){$http.get('

javascript - Jasmine : Timeout - Async callback was not invoked within timeout

我需要测试一个从url加载图像的AngularJs服务。这是我的服务:/*globalangular,Image*/(function(){'usestrict';functionSourceLoader($q,$log){/***Loadanimagefromurlandreturnapromisewhichisresolvedwhenimageisloadingisdone.*Itreturntheimagesobjectasresolvedpromise.*@paramurlsourceoftheimage*@returns{Promise}unresolvedpromiseof

javascript - 将参数传递给 AngularJS $timeout

我正在开发一个ionic移动应用程序,我需要将参数传递给$timeoutpromise,以便我可以使用该参数进行一些操作。我阅读了有关$timeout(https://docs.angularjs.org/api/ng/service/$timeout)的angularjs文档,它说最后一个参数可以是传递给超时函数的参数。我试过这个:$timeout(function(params){alert(params.p1+"-"+params.p2);},5000,true,{p1:"Hello",p2:"World"});但它不起作用,我无法访问超时函数内的params变量。我做错了什么吗

Javascript : Insane boolean test with '!' operator

这个问题在这里已经有了答案:Checklegalcharactersbyregularexpressionbutwithunexpectedresult(2个答案)关闭7年前。在chrome控制台中输入以下函数调用:(function(regex,str){console.log(regex.test(str))console.log(!regex.test(str))console.log(!regex.test(str))console.log(!regex.test(str))console.log(!regex.test(str))})(newRegExp("new","gmi

javascript - 它是 Ecmascript 中的错误 -/\S/.test(null) 返回 true 吗?

在Actionscript3和Javascript中,这些语句给出相同的结果:/\S/.test(null)=>true/null/.test(null)=>true/m/.test(null)=>false/n/.test(null)=>true在这种情况下,null值似乎被转换为字符串“null”。这是Ecmascript中的已知错误还是我遗漏了什么? 最佳答案 这不是错误,但你是对的,null强制到'null'并且该行为在规范中定义:RegExp.prototype.test(string),在内部等效于表达式:RegExp.

javascript - 链接 Angular $timeout

我正在尝试将调用链接到AngularJS的$timeout函数。我在这里看到很多线程允许链接promise,有些线程专门使用Angular的$q,但这看起来应该非常简单。我想我错过了一些明显的东西。这是我喜欢做的事情:$timeout(firstFunction,firstDelay).then($timeout(secondFunction,secondDelay)).then($timeout(thirdFunction,thirdDelay));当所有三个函数都被调用时,$timeout会同时启动。我明白为什么这不起作用,但是如何我如何得到我想要的?我什至可以在这里使用promi

javascript - 哪个更快 : if (var == 'value' ) OR if (/value/. test(var))

哪个更快:if(var=='value')或if(/value/.test(var)) 最佳答案 if(var=='value')。很多。但是,如果您真的想要快,请执行if(var==='value')。与类型强制等效相比,严格等效要做的工作要少得多。 关于javascript-哪个更快:if(var=='value')ORif(/value/.test(var)),我们在StackOverflow上找到一个类似的问题: https://stackoverfl