tdd

How to Mock a Custom Type in Rspec-Puppet

Deadly 提交于 2019-12-03 22:17:01
I am able to test custom types using rspec-puppet due to implementing the answer of this question. However, I would like to avoid to create a symlink to the custom folder in every puppet-module by mocking cystom types . The question is how to mock Custom Puppet Types in Rspec-Puppet. I have found an example regarding the mocking of a Custom Puppet Function but I am looking for an example to mock Puppet Custom Types . Puppet Code class vim::ubuntu::config { custom_multiple_files { 'line_numbers': ensure => 'present', parent_dir => '/home', file_name => '.vimrc', line => 'set number'; } } Rspec

Can phpunit use multiple data provider

丶灬走出姿态 提交于 2019-12-03 22:09:38
One question in short: can phpunit use multiple data provider when running test? For example, I have a method called getById, and I need to run both successful and unsuccessful testcases for it. The successful testcases means that it can return a corresponding record. And for the unsuccessful, the input can fall in two categories: invalid and failed. The invalid means that the input is not legal, while failed means the input could be valid, but there is no corresponding record with that ID. So the code goes like this: /** * @dataProvider provideInvalidId * @dataProvider provideFailedId */

Unit Testing: Creating a 'mock' request to simulate a MVC page request

天大地大妈咪最大 提交于 2019-12-03 22:02:20
How do I go about creating a mock request for my asp.net-mvc application for unit-testing? What options do I have? I am using FormsCollection in my Actions so I can simulate form input data also. labilbe You just have to create a new instance of FormCollection and add the data inside of it. So you can call something like this without mocking anything. var result = controller.Create(new FormCollection { { "InvoiceId", "-1" } }) as RedirectToRouteResult; Otherwise if your code calls something like Request or HttpContext you can use the following extension method (inspired from Scott Hanselman's

Rails: Unit testing a before_create?

别说谁变了你拦得住时间么 提交于 2019-12-03 21:37:10
I am trying to test that a field is being generated properly by a callback, but I can't figure this one out. album.rb before_create :generate_permalink private def generate_permalink @title = album.downcase.gsub(/\W/, '_') @artist = artist.downcase.gsub(/\W/, '_') self.permalink = @artist + "-" + @title end album_test.rb test "should return a proper permalink" do album = Album.new(:artist=>'Dead Weathers', :album=>'Primary Colours') album.save assert_equal "dead_weathers-primary_colours", album.permalink end But this doesn't work because album.permalink won't return the value if it's saved. Is

How to test a COM dependent object in C#

半腔热情 提交于 2019-12-03 20:59:44
问题 I´m trying to do TDD with an object that has a dependency on a COM Interface. I though about mocking the COM interface, while doing development testing, and do it real on the integration tests. However, I cannot mock the COM interface, I tried with Moq, and it throws an exception: System.TypeLoadException was unhandled by user code Message=Could not load type 'Castle.Proxies.iTunesAppProxy' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The

How Do You Keep Automated Tests in Synch With Test Plans

£可爱£侵袭症+ 提交于 2019-12-03 17:21:51
Everyone can agree that it's helpful to have many automated tests (system tests and unit tests) and to have written test plans. But how do you keep those tests synchronized with your Test Case Management tool or with your written test plans? In particular, how do you avoid the awkwardness of needing to update tests in both places? I'm not aware of any silver bullet solution for this. To my knowledge there is no round-trip testing system. I think it will be necessary to update your test plan as you implement new tests. Another option is to leave the test plan a little less specific and use it

Getting Started with TDD?

試著忘記壹切 提交于 2019-12-03 17:19:50
问题 We are in the initial phase of trying to implement TDD. I demo'd the Visual Studio Team System code coverage / TDD tools and the team is excited at the possibilities. Currently we use Devpartner for code coverage, but we want to eliminate it because its expensive. We have very limited experience in TDD and want to make sure we don't go a wrong direction. Currently we are using SourceSafe for source control but will be migrating to Team System in about a year. I can tell you our applications

how to avoid returning mocks from a mocked object list

梦想的初衷 提交于 2019-12-03 17:07:21
问题 I'm trying out mock/responsibility driven design. I seem to have problems to avoid returning mocks from mocks in the case of objects that need a service to retrieve other objects. An example could be an object that checks whether the bills from last month are paid. It needs a service that retrieves a list of bills. So I need to mock that billRetrievalService in my tests. At the same time I need that BillRetrievalMock to return mocked Bills (since I don't want my test to rely on the

Testing: How to test that view contains desired data

纵然是瞬间 提交于 2019-12-03 16:37:14
Say a Chef can make Recipes, and Sous-Chefs can create Recipes that must be approved by a Head Chef. You want to test that, when a Head Chef views her homepage, she sees Recipes that she herself created. You also want to test that she sees there are Recipes awaiting her approval. I can think of two ways to do this: Test that the view contains certain words, like "Your recipes" and "Recipes awaiting your approval" Add unnecessary attributes to the html elements you're using so that you can check for an element with "id=recipe_1" or "data-for-the-sake-of-testing=1" I very much dislike both of

SenTestingKit (integrated with XCode) versus GHUnit on XCode 4 for Unit Testing?

余生颓废 提交于 2019-12-03 15:51:24
Any advice on which way to go regarding Unit Testing on XCode 4 out of SenTestingKit (the inbuild unit testing framework with XCode 4) and GHUnit? In particular: With the apparent improvements to Unit Testing in XCode 4 does this mean there are no major benefits of running with GHUnit? Alternatively are there some integration benefits that make a smooth development process that could be achieved using XCode's unit testing framework (SenTestingKit) as opposed to GHUnit? Greg, I answered your question on my blog, about 2 weeks late :). The conclusion I came to is the GHUnit isn't obsolete, but