tdd

How to mock static method in Java?

佐手、 提交于 2019-12-01 09:16:36
I have a class FileGenerator , and I'm writing a test for the generateFile() method that should do the following: 1) it should call the static method getBlockImpl(FileTypeEnum) on BlockAbstractFactory 2) it should populate variable blockList from the subclass method getBlocks() 3) it should call a static method createFile from a final helper class FileHelper passing a String parameter 4) it should call the run method of each BlockController in the blockList So far, I have this empty method: public class FileGenerator { // private fields with Getters and Setters public void generateBlocks() { }

Anyone done an Objective-C Xode version of Osherove´s TDD Kata “String Calculator”?

落爺英雄遲暮 提交于 2019-12-01 08:35:33
Always trying to code better and I am interested in doing TDD for Objective-C and Xcode. Do you know any post that implement something like Roy Osherove´s "String Calculator"-Kata Update: trying to find out how to speed up TDD on iOS I did that. You can find the screencast and the Xcode project here in my blog . I’ve written the text around it in german, but you should have no trouble playing the video or finding the download link. I'd use NSPredicate like this: NSPredicate * parsed = [NSPredicate predicateWithFormat:@"6 * 7 = 0"]; NSExpression * left = [(NSComparisonPredicate *)parsed

Unit testing value objects in isolation from its dependencies

怎甘沉沦 提交于 2019-12-01 08:30:02
TL;DR How do you test a value object in isolation from its dependencies without stubbing or injecting them? In Misko Hevery's blog post To “new” or not to “new”… he advocates the following (quoted from the blog post): An Injectable class can ask for other Injectables in its constructor.(Sometimes I refer to Injectables as Service Objects, but that term is overloaded.). Injectable can never ask for a non-Injectable (Newable) in its constructor. Newables can ask for other Newables in their constructor, but not for Injectables (Sometimes I refer to Newables as Value Object, but again, the term is

“Code covered” vs. “Code tested”?

安稳与你 提交于 2019-12-01 08:14:05
问题 Converting my current code project to TDD, I've noticed something. class Foo { public event EventHandler Test; public void SomeFunction() { //snip... Test(this, new EventArgs()); } } There are two dangers I can see when testing this code and relying on a code coverage tool to determine if you have enough tests. You should be testing if the Test event gets fired. Code coverage tools alone won't tell you if you forget this. I'll get to the other in a second. To this end, I added an event

Exit Protractor e2e test on fail?

只愿长相守 提交于 2019-12-01 05:45:09
Does anyone out there know if there is a config that can be added to protractor's e2e.conf.js so it exits the test once it fails? Default behaviour is that if a test fails early on, you need to wait until it finishes to fix the error. From a workflow perspective, this is very frustrating. Any solutions to this problem? Thanks no this option is missing. you could implement jasmine-bail-fast 来源: https://stackoverflow.com/questions/25496290/exit-protractor-e2e-test-on-fail

Chai assertion testing whether object structure contains at least other object structure

孤街浪徒 提交于 2019-12-01 05:18:47
I'm using Mocha for unit testing and Chai for assertions. I'd like to find an easy to use solution to check if an object has the structure and properties as defined in my comparison object. But I don't need the objects to be completely equal. The subject under test should contain at least all the properties in my test object, but it might also contain other properties which are not under test at that moment. So, I want to test a unit to check if the object it returns has at least a property named 'foo', which itself is an object that at least contains the property 'bar' with value 10. So, I

Capybara + RSpec only sees blank pages in controller specs. Why?

可紊 提交于 2019-12-01 05:17:52
I'm trying to write a controller spec for a simple controller. However, Capybara isn't seeing any page content. However, looking at the site's pages in my browser works just fine. What am I doing wrong? T. Hanks! My controller spec My spec_helper.rb My Gemfile You need to explicitly tell your controller spec that you want it to render views in order for this to work. Update your spec to look like this: require 'spec_helper' describe PostsController do render_views # Render this controller's views during spec execution. before do @post = Fabricate :post end # ... end This is described in rspec

How to define a simple global variable in an rspec test that can be accesed by helper functions

筅森魡賤 提交于 2019-12-01 04:15:23
I cant figure out how to use a simple global variable in an rspec test. It seems like such a trivial feature but after much goggleing I havent been able to find a solution. I want a variable that can be accessed/changed throughout the main spec file and from functions in helper spec files. Here is what I have so far: require_relative 'spec_helper.rb' require_relative 'helpers.rb' let(:concept0) { '' } describe 'ICE Testing' do describe 'step1' do it "Populates suggestions correctly" do concept0 = "tg" selectConcept() #in helper file. Sets concept0 to "First Concept" puts concept0 #echos tg??

Windows Phone 7 mocking framework?

巧了我就是萌 提交于 2019-12-01 04:06:17
Are there any mocking frameworks for Windows Phone 7 or do I need to create fakes manually? I've not found any on google, and although I found Moq listed on WP7 resources page, I couldn't get it working. There are no Mocking frameworks that support WP7 and I suspect there will never be any until WP7 supports Reflection.Emit. On the .net framework there are many options that exist for the creation of a mocking framework (Profiler API, CodeDem, Refleciton.Emit, et al). The majority of these techniques won't work on Silverlight itself as it's missing quite a lot of the BCL/CLR. All existing

Static Methods : When and when not

谁说胖子不能爱 提交于 2019-12-01 03:51:25
I am new to TDD and DDD and I have one simple question regarding static methods in general. Most of the gurus of TDD says in one word that static methods are bad (and that we should forget about creating tons of static utilities that we (um or I) used to make before as they are not testable. I can see why they are not testable ( a great clarification article can be found here for those who are interested but I guess I am the only noob here :( ) but I was wondering is there a nice and clean guideline for using statics from TDD point of view? This may be really silly question for most of you but