tdd

How do I put new List<int> {1} in an NUNIT TestCase?

房东的猫 提交于 2019-11-27 13:31:04
问题 I have the method: public static int Add(List<int> numbers) { if (numbers == null || numbers.Count == 0) return 0; if (numbers.Count == 1) return numbers[0]; throw new NotImplementedException(); } Here is my test against it, but it does not like new List<int> {1} in the TestCase: [TestCase(new List<int>{1}, 1)] public void Add_WithOneNumber_ReturnsNumber(List<int> numbers) { var result = CalculatorLibrary.CalculatorFunctions.Add(numbers); Assert.AreEqual(1, result); } It gives me the error:

Does TDD apply well when developing an UI?

只谈情不闲聊 提交于 2019-11-27 13:07:41
问题 What are your opinions and experiences regarding using TDD when developing an user interface? I have been pondering about this question for some time now and just can't reach a final decision. We are about to start a Silverlight project, and I checked out the Microsoft Silverlight Unit Test Framework with TDD in mind, but I am not sure how to apply the approach to UI-development in general - or to Silverlight in particular. EDIT: The question is about if it is practical thing to use TDD for

How to mock a function call on a concrete object with Moq?

不打扰是莪最后的温柔 提交于 2019-11-27 12:47:18
问题 How can I do this in Moq? Foo bar = new Foo(); Fake(bar.PrivateGetter).Return('whatever value') It seems I can only find how to mock an object that was created via the framework. I want to mock just a single method/property on a concrete object I've created. In TypeMock, I would just do Isolate.WhenCalled(bar.PrivateGetter).Returns('whatever value') . Any ideas? 回答1: Only TypeMock Isolator (and perhaps Moles) can perform these stunts. Normal dynamic mock libraries can only mock virtual and

Test cases for go and appengine

♀尐吖头ヾ 提交于 2019-11-27 12:43:09
问题 I am using Go and appengine, and now I would like to do some test cases. I tried using gos standard test package, Files (both "package hello"): hello/http.go hello/http_test.go Problem: I cannot run go test hello . The closest I have got is go test hello/http_test.go which works if I do not make any calls to http.go , which is quite pointless. :) 回答1: An interesting development: as of 1.8.6 using service stubs for testing has been integrated into the SDK through the "appengine/aetest" package

“Web interface” to PHPUnit tests?

爷,独闯天下 提交于 2019-11-27 11:46:16
Is there a simple "Web interface" to running PHPUnit test suites? i.e. a PHP script that runs the test on the command line, and outputs a nicely formatted HTML result. I develop web applications, and the day-to-day workflow usually switches between the IDE and the browser. I would like to have the unit testing in the same environment. I'm looking for something really simple and PHP based - I am planning to get into phpUnderControl (which has the functionality I'm looking for) but not yet. You can use phing to run a PHPUnitTask and then convert the output with: PHPUnitReport - This task

How do you unit test an interface?

流过昼夜 提交于 2019-11-27 11:37:37
问题 For example, there is a interface IMyInterface , and three classes support this interface: class A : IMyInterface { } class B : IMyInterface { } class C : IMyInterface { } In the simplest way, I could write three test class : ATest, BTest, CTest and test them separately. However, since they support the same interface, most test code would be the same, it's hard to maintain. How can I use a simple and easy way to test a interface that is supported by different class? (previously asked on the

How to include Rails Helpers on RSpec

不想你离开。 提交于 2019-11-27 11:29:22
问题 I'm trying to include some helpers to test with rspec but no luck. What I did: created a support/helpers.rb file under my spec folder. support/helpers.rb module Helpers include ActionView::Helpers::NumberHelper include ActionView::Helpers::TextHelper end and tried to require this file in spec_helper.rb . # This file is copied to spec/ when you run 'rails generate rspec:install' require 'rubygems' require 'spork' require 'support/helpers' Spork.prefork do . . end this generates the following

Unit Testing Guidelines

风流意气都作罢 提交于 2019-11-27 11:13:57
问题 Does anyone know of where to find unit testing guidelines and recommendations? I'd like to have something which addresses the following types of topics (for example): Should tests be in the same project as application logic? Should I have test classes to mirror my logic classes or should I have only as many test classes as I feel I need to have? How should I name my test classes, methods, and projects (if they go in different projects) Should private, protected, and internal methods be tested

Run logic tests in Xcode 4 without launching the simulator

孤街醉人 提交于 2019-11-27 11:10:41
问题 I want to run tests in Xcode 4 using OCUnit without launching the simulator. Please, don't try and convince me I am doing unit testing wrong or anything like that. I like to do TDD the traditional way: write the API for the class in the tests, then make the class pass the tests. I will write separate tests that are end-to-end that run in the simulator. If there's no way to do this, then please can someone tell me how to have the test harness not instantiate the whole app? My app is event

TDD and ADO.NET Entity Framework

℡╲_俬逩灬. 提交于 2019-11-27 10:56:52
问题 I've been playing with ADO.NET Entity Framework lately, and I find that it suits my needs for a project I'm developing. I also find cool its non-invasive nature. After generating a data model from an existing database you are faced with the task of integrating the generated model and your business logic. More specifically, I'm used to integration-test my classes that interact with the data store via mocks/stubs of the DAL interfaces. The problem is that you cannot do this using the ADO.NET