tdd

Unit testing a class with no return value?

孤街醉人 提交于 2019-12-08 22:56:55
问题 I didn't find much in tutorials on this specific question.. So I have a class called 'Job' which has public ctors and a single public Run() function. Everything in the class is private and encapsulated in the class. (You may remember an older post here on this Testing only the public method on a mid sized class?, which replies helped me greatly) This Run() method does a bunch of things - takes an excel file as input, extracts data out of it, sends a request to a third party data vendor, takes

my rspec test won't pass: Michael Hartl's rails tutorial

假装没事ソ 提交于 2019-12-08 21:33:14
问题 I am at the end of chapter five doing the exercises. I am supposed to be testing that the links go to the correct pages. Here is my test code. require 'spec_helper' describe "LayoutLinks" do it "should have the right links on the layout" do visit root_path click_link "About" response.should have_selector('title', :content => "About") click_link "Home" response.should have_selector('title', :content => "Home") click_link "Help" response.should have_selector('title', :content => "Help") click

Could current approach to TDD in Servlets be optimized?

ぃ、小莉子 提交于 2019-12-08 19:41:29
The current approach is creating HTML in a ServletTest, run the test, change the Servlet until the test turns into green. However, it feels like that this approach to TDD in Servlets is devious and more time-consuming than TDD ordinary Java classes as HTML created in the ServletTest is copied to the Servlet for the most part and subsequently changed regarding the format (e.g. removing backslashes) instead of testing the output in a Test for ordinary Java Classes and writing most of the code in the main. ServletTest: HttpServletRequest mockedHttpServletRequest = mock(HttpServletRequest.class);

Accessing session from a helper spec in rspec

二次信任 提交于 2019-12-08 19:01:27
问题 I have a method in my ApplicationHelper that checks to see if there are any items in my basket module ApplicationHelper def has_basket_items? basket = Basket.find(session[:basket_id]) basket ? !basket.basket_items.empty? : false end end Here is my helper spec that I have to test this: require 'spec_helper' describe ApplicationHelper do describe 'has_basket_items?' do describe 'with no basket' do it "should return false" do helper.has_basket_items?.should be_false end end end end however when

Capybara:Webkit unable to find iframe or its content

有些话、适合烂在心里 提交于 2019-12-08 17:12:09
问题 I allow users to share photos with other individuals. When the user is viewing a photo and its description, they can click on "share" and a new page loads. On this page the fill in an email address (and optional comments - not tested here) and click "Share Photo". The systems sends an email to the recipient with a link contained and the subject line includes the name of the photo. The page with the Share form also displays a list of individuals the photo has already been shared with. The full

Is mockito supposed to call default constructor of mocked class?

无人久伴 提交于 2019-12-08 16:30:06
问题 I'm trying to create a Mockito mock object of a class with some rather heavy network and transaction behavior which I don't want to have to deal with in the current unit test I'm writing. It does however seem like Mockito calls the default constructor of the actual class when instantiating the mock object. The default constructor does all kinds of things that causes problems in the context of this unit test. Is Mockito supposed to invoke the default constructor? And is there any way to avoid

Should I start using TDD on a project that doesn't use it already

ε祈祈猫儿з 提交于 2019-12-08 14:55:43
问题 I have a project that I have been working on for a while, just one of those little pet projects that I would like to one day release to open source. Now I started the project about 12 months ago but I was only working on it lightly, I have just started to concentrate a lot more of my time on it(almost every night). Because it is a framework like application I sometimes struggle with a sense of direction due to the fact I don't have anything driving my design decisions and I sometimes end up

Rhino Mocks - How to assert a mocked method was called n-times?

邮差的信 提交于 2019-12-08 14:48:31
问题 How can i assert that a method on a mocked object was called exactly called n-times? Here is the code snippet from a controller action, i like to test: for (int i = 0; i <= newMatchCommand.NumberOfMatchesToCreate; i++) { serviceFacade.CreateNewMatch("tester", Side.White); } The "service facade" object is the (strict) mock and will be injected into the controller. The unit test should assert that the CreateNewMatch method within the action was called n-times. (e.g. 5) 回答1: Try Expect.Call

How do I test if a function calls a specific method/function?

拈花ヽ惹草 提交于 2019-12-08 14:43:56
问题 Is there a way in Mocha to test if a function calls a specific method or external function? I am using Mocha with Chai, but am open to any other assertion libraries. Ok, so testing whether a methid is being called is pretty easy using sinon. I'm not sure about testing to see if an external function is being called though. So I updated the examples to represent something a little more "real world". I am working on a node app, so foo.js and bar.js are both modules. Example: foo.js var bar =

TestDriven.NET is not running my SetUp methods for MbUnit

♀尐吖头ヾ 提交于 2019-12-08 14:36:16
问题 I've created some MbUnit Test Fixtures that have SetUp methods marked with the SetUp attribute. These methods run before the tests just fine using the MbUnit GUI, the console runner, and the ReSharper MbUnit plugin. However, when I run the tests with TestDriven.NET it does not run the SetUp methods at all. Does anyone know if this is a bug with TestDriven.NET or if I have something setup wrong? 回答1: No longer an issue with recent versions of Gallio since v3.0.4. Just make sure to use the 64