tdd

How do I add a fakes assembly in VS 2012 Professional RC?

霸气de小男生 提交于 2019-12-05 08:33:36
问题 According to the two articles below on VS 2012 and Microsoft Fakes Test Framework, I should be able to right click on an assembly in my test project's references and choose "Add Fakes Assembly" to create a new Microsoft Fakes Framework Assembly in Visual Studio 11 / 2012. However I do not find the context menu item in VS 2012 RC Professional where it should be. I may need to reference the Microsoft.QualityTools.Testing.Fakes assembly, but I cannot find it in the add reference search either.

What is the purpose of unit testing an interface repository

拜拜、爱过 提交于 2019-12-05 08:07:47
I am unit testing an ICustomerRepository interface used for retrieving objects of type Customer . As a unit test what value am I gaining by testing the ICustomerRepository in this manner? Under what conditions would the below test fail? For tests of this nature is it advisable to do tests that I know should fail? i.e. look for id 4 when I know I've only placed 5 in the repository I am probably missing something obvious but it seems the integration tests of the class that implements ICustomerRepository will be of more value. [TestClass] public class CustomerTests : TestClassBase { private

I am having trouble testing my controller's update action using Rspec, what am I doing wrong?

我怕爱的太早我们不能终老 提交于 2019-12-05 08:01:01
问题 I am trying to test the failing branch of the update action on my controller but I am having trouble with the test. This is what I have and it fails on the last describe "PUT 'article/:id'" do . . . describe "with invalid params" do it "should find the article and return the object" do Article.stub(:find).with("1").and_return(@article) end it "should update the article with new attributes" do Article.stub(:update_attributes).and_return(false) end it "should render the edit form" do response

TDD: Help with writing Testable Class

╄→尐↘猪︶ㄣ 提交于 2019-12-05 07:54:48
I have a quick little application and wanted to give a try to develop using TDD. I've never used TDD and actually didn't even know what it was until I found ASP.NET-MVC. (My first MVC app had unit tests, but they were brittle, way coupled, took too much up keep, and were abandoned -- I've come to learn unit tests != TDD). Background on app: I have a text dump of a purchase order read in as a string. I need to parse the text and return new purchase order number, new line item number, old purchase order number, old purchase order line number. Pretty simple. Right now I'm only working on new

How to Mock a Custom Type in Rspec-Puppet

痴心易碎 提交于 2019-12-05 07:08:02
问题 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

Mock implementations in C++

爱⌒轻易说出口 提交于 2019-12-05 06:19:45
I need a mock implementation of a class - for testing purposes - and I'm wondering how I should best go about doing that. I can think of two general ways: Create an interface that contains all public functions of the class as pure virtual functions, then create a mock class by deriving from it. Mark all functions (well, at least all that are to be mocked) as virtual . I'm used to doing it the first way in Java, and it's quite common too (probably since they have a dedicated interface type). But I've hardly ever seen such interface-heavy designs in C++, thus I'm wondering. The second way will

Nock is not intercepting API call in Redux test

不羁的心 提交于 2019-12-05 04:40:06
I'm trying to test an api call in a redux app. The code pretty much follows the pattern outlined in the Async Action Creators section of the redux docs: http://redux.js.org/docs/recipes/WritingTests.html The gist of it is that you use redux-mock-store to record and assert against any actions that are triggered. This is the whole test, using nock to mock the api call: import React from 'React' import ReactDOM from 'react-dom' import expect from 'expect'; import expectJSX from 'expect-jsx'; import TestUtils from 'react-addons-test-utils' import configureMockStore from 'redux-mock-store' import

Should I unit test for multithreading problems before writing any lock?

霸气de小男生 提交于 2019-12-05 04:14:31
I am writing a class that I know that needs a lock, because the class must be thread safe. But as I am Test-Driven-Developing I know that I can't write a line of code before creating a test for it. And I find very difficult to do since the tests will get very complex in the end. What do you usually do in those cases? There is any tool to help with that? This question is .NET specific Someone asked for the code: public class StackQueue { private Stack<WebRequestInfo> stack = new Stack<WebRequestInfo>(); private Queue<WebRequestInfo> queue = new Queue<WebRequestInfo>(); public int Count { get {

PHPSpec Catching TypeError in PHP7

偶尔善良 提交于 2019-12-05 04:12:40
I want test an example method with scalar type hinting and strict types in PHP7. When I don't pass an argument, the method should throw a TypeError . PHPSpec return fatal error: Uncaught TypeError: Argument 1 passed to Example::test <?php class Example { public function test(string $name) { $this->name = $name; } } class ExampleSpec extends ObjectBehavior { function it_is_initializable() { $this->shouldHaveType('Test\Example'); } function it_check_test_method_when_not_pass_argument() { $this->shouldThrow('\TypeError')->during('test'); } } At the beginning I declare: declare(strict_types=1);

Cython & Python Project Test Driven Development and .pyx file structure advice

限于喜欢 提交于 2019-12-05 03:06:00
What is the best way to structure a python/cython project such that I can unit test code that resides in .pyx files? Is it possible to unit test this code in place or will refactoring allow me to achieve this in another way? I am new to cython but have experience with Python TDD, mocking etc. I am also aware that the decision to cythonise some of the python code base could have been a premature optimisation decision. I have just joined a new team and therefore I am working on an existing code base. I am trying to get a feel for best practices. Also in PyCharm, modules written in .pyx files are