tdd

What is the difference between overload and alias in Mockery?

三世轮回 提交于 2019-12-03 15:07:52
I am new to using Mockery and confused with the terminology alias and overload . Can anyone please explain to me when to use which? Overload is used to create an "instance mock". This will "intercept" when a new instance of a class is created and the mock will be used instead. For example if this code is to be tested: class ClassToTest { public function methodToTest() { $myClass = new MyClass(); $result = $myClass->someMethod(); return $result; } } You would create an instance mock using overload and define the expectations like this: public function testMethodToTest() { $mock = Mockery::mock(

Does NUnit's Is.EqualTo not work reliably for classes derived from generic classes?

不打扰是莪最后的温柔 提交于 2019-12-03 14:07:56
Today I ran into the following problem with NUnit. I have a class, that derives from a generic class. I started to do some serialization tests and tested for equality using the Is.EqualTo() function of NUnit. I started to suspect something is wrong, when a test that should have failed passed instead. When I used obj1.Equals(obj2) instead it failed as it should. To investigate I created the following tests: namespace NUnit.Tests { using Framework; public class ThatNUnit { [Test] public void IsNotEqualTo_ClientsNotEqual_Passes() { var client1 = new DerrivedClient(); var client2 = new

How to set up separate test and development database in meteor

你。 提交于 2019-12-03 13:53:29
I've written a few tests for my meteor app. As they have setup and teardown methods that remove all documents or populate with new ones, I'd like to run them on a database dedicated to testing. I notice the db is stored in .meteor/local/db . Ideally I'd like to have db_test and db_dev accessed form different ports. Is this possible? Justin Case You'll have to run two mongod processes e.g. # Dev mongod --port 27017 --dbpath .meteor/local/db_dev # Testing mongod --port 28017 --dbpath .meteor/local/db_test [Edit] This should work. Using the leaderboard example project: MONGO_URL="mongodb://127.0

TDD iOS tutorial [closed]

岁酱吖の 提交于 2019-12-03 13:42:56
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Hi I looking for really good tutorial for iOS TDD, would you please help me! what is the best iOS TDD book, blog --> tutorial (I had different research on google but since I don't have enough knowledge about " iOS TDD " I don't know which one is the best) Thanks in advance! 回答1: There are many stuff about TDD on

How to test Ninject ConstructorArguments using MOQ objects?

前提是你 提交于 2019-12-03 13:34:34
问题 I have been doing my first Test Driven Development project recently and have been learning Ninject and MOQ. This is my first attempt at all this. I've found the TDD approach has been thought provoking, and Ninject and MOQ have been great. The project I am working on has not particularly been the best fit for Ninject as it is a highly configurable C# program that is designed to test the use of a web service interface. I have broken it up into modules and have interfaces all over the shop, but

New to TDD: Are there sample applications with tests to show how to do TDD?

回眸只為那壹抹淺笑 提交于 2019-12-03 13:31:37
问题 I really want to get into TDD development but I have no point of reference where to start. I think that looking at code and seeing how they write tests and make classes testable that it'll be easier for me to digest and start using myself. Is anyone aware of any sample or small open source C# applications that include unit tests? 回答1: For shakalpesh, I would recommend the ObjectMentor katas. One is to create a bowling game scoring algorithm Another is to convert infix expressions to postfix.

TDD type methodology for WPF / Silverlight

☆樱花仙子☆ 提交于 2019-12-03 12:59:52
问题 Has anyone got a TDD-ish methodology for designing complex WPF xaml components (i.e., ControlTemplates, Custom Controls with dependency properties)? Is eyeballing the UI the closest you can come to asserting your code is correct? How about incremental development; any aids to dividing up the logic incrementally? If there isn't any methodologies for doing this now, do you think there will be as the platform continues to mature and gain adoption? Cheers, Berryl To be more focused and avoid

Testing password length validation with RSpec

岁酱吖の 提交于 2019-12-03 12:39:46
I'm writing some unit tests to ensure a User model cannot have a password < 8 characters long. I started with a User model: class User < ActiveRecord::Base ... validates :password, :length =>{ :minimum => 90, :too_short => "password is too short, must be at least %{count} characters" }, :on => :create end And a user_spec.rb test: describe User do subject { FactoryGirl.build :user } its(:password) { should have_at_least(8).items } end However I realised that this doesn't actually test my validation, it just tests that my factory had a password >= 8 characters. Is there a nice way to do this

Ruby on Rails functional test with Devise authentication

你说的曾经没有我的故事 提交于 2019-12-03 12:38:27
问题 I'm searching for a solution for a weird problem. I have a controller, that needs authentication (with the devise gem). I added the Devise TestHelpers but i can't get it working. require 'test_helper' class KeysControllerTest < ActionController::TestCase include Devise::TestHelpers fixtures :keys def setup @user = User.create!( :email => 'testuser@demomailtest.com', :password => 'MyTestingPassword', :password_confirmation => 'MyTestingPassword' ) sign_in @user @key = keys(:one) end test

Does TDD mean not thinking about class design?

断了今生、忘了曾经 提交于 2019-12-03 12:30:02
问题 I am making a role playing game for fun and attempting to use TDD while developing it. Many of the TDD examples I see focus on creating the test first, then creating objects that are needed to get the test to pass. For example: [Test] public void Character_WhenHealthIsBelowZero_IsDead() { // create default character with 10 health Character character = new Character(); character.SubtractHealth(20); Assert.That(character.IsAlive, Is.EqualTo(false)); } So based on this I'll create the character