草庐IT

Test_stub

全部标签

ruby - 当一个对象的构造函数构建另一个对象时 stub

所以我有一些代码,粗略地简化后,看起来像这样:classBdefinitializeopts@opts=optsendendclassAdefinitializeopts#defaultsetcappliedtoopts@b=B.newoptsendend换句话说,当我用选项初始化A时,它会创建一个B并将一组修改后的选项传递给它。我想测试B.new是否获得正确的参数。现在,我正在这样做,使用RSpec/RR:@b=Object.new#stubmethodson@bherestub(B).new{|options|options[:foo].should=='whatever'@b}A

arrays - 为什么Ruby Koans习题中about_hashes.rb中的test_default_value_is_the_same_object的答案是数组?

我正在做ruby​​koans练习,我有点困惑为什么test_default_value_is_the_same_object方法练习中的答案是这样的。下面是代码:deftest_default_value_is_the_same_objecthash=Hash.new([])hash[:one]我不确定为什么不管键是什么,值总是“uno”和“dos”?我想当键是one时,返回值应该是“uno”;当键为“二”时,返回值应为“dos”。为什么不管键是什么,值总是一个数组?谢谢你,我期待着你的回答! 最佳答案 hash=Hash.new

javascript - Jest : Change output of manual mock for different tests within a test suite

假设我有以下两个文件://index.js...import{IS_IOS}from'common/constants/platform';...exportconstmyFunction=()=>(IS_IOS?'foo':'bar');//index.test.js...import{myFunction}from'./index';jest.mock('common/constants/platform',()=>({IS_IOS:true}));describe('Mytest',()=>{it('testsbehavioronIOS',()=>{expect(myFuncti

javascript - JQuery - $ ('#test ul > li' ).index(2).hide(); - 可能的?

我可以如此轻松地使用索引值吗?我认为使用自然索引值比使用类更好。我想以这种方式使用.index。HTMLImindex0Imindex1Imindex2Imindex3伪(Jquery)Javascript$('#testul>li').index(2).hide();$('#testul>li').index(1).click(function(){alert('lulzyouclickedtheliwiththeindexvalueof1bro');});我没有找到如何使用.index值以这种方式工作的线索。是否可以使用这种方法轻松工作? 最佳答案

javascript - stubbing process.exit 开 Jest

我有代码可以做类似的事情functionmyFunc(condition){if(condition){process.exit(ERROR_CODE)}}我如何在Jest中测试它?用jest.fn()覆盖process中的exit并在测试不起作用后将其返回,因为进程退出 最佳答案 此线程中的其他建议会导致我这边出现错误,任何使用process.exit的测试都会无限期地运行。以下选项适用于TypeScript,但它也适用于JavaScript:constmockExit=jest.spyOn(process,'exit').moc

javascript - Vue-Test-Utils 的 "mount"和 "shallowMount"之间的区别?

免责声明:我对Vue、JavaScript和一般的Web框架还很陌生。我正在尝试使用Jest和vue-test-utils熟悉一些基本的单元和组件测试。我已经阅读了关于vue-test-utils的文档'mount()和shallowMount(),但我不确定何时使用其中一个(它们看起来非常相似)。根据shallowMount()上的文档:Likemount,itcreatesaWrapperthatcontainsthemountedandrenderedVuecomponent,butwithstubbedchildcomponents.“stub子组件”到底是什么意思?mount

docker -/bin/sh : 1:/go/src/test. sh: 未找到

我正在尝试构建这个dockerfile,该文件已成功复制,但我不断收到以下错误:dockerbuild--no-cache=true-fDockerfile-Gobase。SendingbuildcontexttoDockerdaemon34MBStep1/3:FROMgolang:1.11.2--->df6ac9d1bf64Step2/3:COPY./test.sh/go/src/--->38a538f0289dStep3/3:RUN(ls-l/go/src/&&cd/go/src/&&/go/src/test.sh)--->Runningin089de53d11f0total4-r

c# - VS 团队测试 : Multiple Test Initialize Methods in Test Class

我在TeamTest中有一个名为“MyClassTest”的单元测试项目。该项目具有三个TestMethods。每个方法都需要自己的测试初始化​​步骤。但是当我将TestInitializeAttribute应用于三个初始化方法时,它说该属性不应多次使用。那么在VisualStudioTeamTest中初始化每个测试方法的属性应该是什么?引用:VSTeamTest:.NetUnitTestingwithExcelasDataSource:AdapterFailedHowtocreateStartupandCleanupscriptforVisualStudioTestProject?V

php - Phar 存档和 stub 文件的使用

我尝试根据命令定义部署过程:php.phar此命令在phar存档外部生成一个index.php文件。index.php文件将充当phar存档内N-file.php的“瘦”调度程序。生成的index.php文件示例:.phar";/***Forexampleindex.phpcancheck$_GETarrayanddispatch*tofileinsidePhararchive.**/if(array_key_exists("getParameter",$_GET))$requiredFile=$requiredFile."/".$_GET['getParameter'].".php"

java - 使用 Logback-test.xml 将时间戳添加到日志文件

目前我的Spring-boot应用程序记录到一个名为:myLog.log的文件,这是按预期工作的,但是我希望日志文件有一个时间戳并在每次运行时创建一个新文件。我已经尝试在我的logback-test.xml文件中实现它,如下所示,但它只是给我文件名:myLog.log没有时间戳。我该如何解决这个问题?Logback-test.xml:%d{HH:mm:ss.SSS}-%msg%npath/to/my/file/mylog.log%d{yyyy-MM-dd_HH:mm:ss.SSS}-%msg%nmylog.%i{yyyy-MM-dd_HH:mm:ss.SSS}}.log1102MB