tdd

Configuring Nunit with ASP.NET MVC Core 1.0

青春壹個敷衍的年華 提交于 2019-12-13 08:24:38
问题 I wanted to configure NUnit for my ASP.NET Core 1.0 project. I have tried following : http://www.alteridem.net/2015/11/04/testing-net-core-using-nunit-3/ , but it's there for console applications. If I try to attach a new project (class library) to my solution and then try to reference my original project - it gives me reference error. Here is what worked for me: I attached another web app project, dedicated to writing tests, to my original project, as opposed to the console library project.

Where to start with test driven development?

断了今生、忘了曾经 提交于 2019-12-13 04:37:07
问题 I'm relatively new to Test Driven Development, and I was just wondering where I should start? I understand how to do the testing. I just mean what should I test first? Is there a best practice for this? Should I test the models first? The controllers? Should I write an integration test first thing, then build everything up from there to make it pass? What are the opinions on this? 回答1: I don't think there's one hard and fast answer on where to start. I personally like to start with my UI

How to unit test code in the repository pattern?

孤街醉人 提交于 2019-12-13 04:02:25
问题 How to test this scenario: I have a user repository that (so far) only has one method: SaveUser . "SaveUser" is suposed to receive a user as a parameter and save it to the DB using EF 6. If the user is new (new user is defined by a "Email" that is not present in the database) the method is supposed to insert it, if its not, the method is supposed to only update it. Technically if this method is called, all business validation are OK, only remaining the act of actually persisting the user My

Can cxxtest suite be dynamically extended at run-time?

好久不见. 提交于 2019-12-13 02:06:12
问题 I wish to dynamically extend my CxxTest Suite with additional test items, but am finding that all the testing scenerios must be available (hard-coded) at compile time. My scenario is that I've got a fairly bulky C++ class that has 20+ methods to be tested. This class needs to be tested for 40+ DIFFERENT data sets. These data sets are obtained via the class constructor, controlled via parameters. My primary objective is to avoid re-writing the same 20 test cases for the different data sets. I

unit testing async-waterfall using mocha

那年仲夏 提交于 2019-12-13 01:47:46
问题 I am using Mocha as a testing framework for my node.js application. I have an existing module that uses async-waterfall node module.I am trying to write a unit test case for it. I am unable to write a test case for the second function in the array. Any tips on how would I pass the result of one function to the next function in the array var async = require('async'); module.exports.resetPassword = function(req,res,next){ async.waterfall([ function(done){ var token = do something; done(err

Unit test method with NSData dataWithContentsOfURL

自作多情 提交于 2019-12-13 01:39:42
问题 I am developing an iOS app and I am trying to do it with test-driven development . I've been reading a lot on the subject and one of the things I came across in a book is that tests are supposed to be fast, repeatable and reliable . As a consequence, when writing a test for networking code, the test should "simulate" the network, so that it can be executed regardless of network availability. In my code I have a method that retrieves an image from the internet with a URL, scales it and stores

How to test functions inside javascript closure

时光总嘲笑我的痴心妄想 提交于 2019-12-12 20:52:27
问题 This seems impossible (and it might be), but I'm trying to get into more TDD and I keep hitting a wall with closures. Say I have the following: function createSomething(init) { function privateMethod(param) { return init[param]; //assuming this is more complicated, how can you test it? } function getData() { return init.data; } function getValue(name) { if (name === "privateNode" || typeof name !== "string") { return "permissionDenied"; } return privateMethod(name); } return { getData :

What causes Cassini to load when I run a unit test [duplicate]

微笑、不失礼 提交于 2019-12-12 18:26:55
问题 This question already has answers here : How do you configure VS2008 to only open one webserver in a solution with multiple projects? (5 answers) Closed 6 years ago . I have a test project for a solution which involves an MVC web application and several class libraries. I am using mock objects and System.Web.Abstractions to avoid dependencies on ASP.NET intrinsic objects. But when I start my test project Cassini loads. If I immediately stop cassini all my tests still pass. So why does it load

How to follow TDD for testing failure on this malloc wrapper?

穿精又带淫゛_ 提交于 2019-12-12 18:01:07
问题 I'm experimenting with TDD and C. I'd like to write a simple malloc wrapper following a TDD approach. I'm trying to follow Bob Martin's Three laws of TDD Do not write production code unless it is to make a failing unit test pass. Do not write more of a unit test than is sufficient to fail, and build failures are failures. Do not write more production code than is sufficient to pass the one failing unit test. This is my code up until now: J_STATUS MemAlloc(long Size, void **OutPtr) { J_STATUS

Unit testing with multiple collaborators

两盒软妹~` 提交于 2019-12-12 17:31:46
问题 Today I ran into a very difficult TDD problem. I need to interact with a server through HTTP POSTs. I found the the Apache Commons HttpClient, which does what I need. However, I end up with a bunch of collaborating objects from Apache Commons: public void postMessage(String url, String message) throws Exception { PostMethod post = new PostMethod(url); RequestEntity entity = new StringRequestEntity(message, "text/xml; charset=ISO-8859-1"); post.setRequestEntity(entity); HttpClient httpclient =