tdd

How often should we write unit tests?

风格不统一 提交于 2019-12-03 09:51:39
I am recently introduced to the test-driven approach to development by my mentor at work, and he encourages me to write an unit-test whenenver "it makes sense." I understand some benefits of having a throughout unit-test suite for both regression testing and refractoring, but I do wonder how often and how throughout we should write unit-test. My mentor/development lead asks me to write a new unit test-case for a newly written control flow in a method that is already being tested by the exsisting test class, and I think it is an overkill. How often do you write your unit tests, and how detailed

How do I tell MSTEST to run all test projects in a Solution?

你离开我真会死。 提交于 2019-12-03 09:49:15
I need to know how to tell MSTEST to run all test projects in a solution file. This needs to be done from the command line. Right now I have to pass it a specific project file, I'm trying to get it to run from a SOLUTION file. I'm hoping this is possible, because in Visual Studio, hitting Ctrl+R, A, runs ALL tests in the currently opened solution. The way I've interpretted the help files, you have to pass in each DLL specifically. I want to run this from the command line from my CruiseControl.NET server, so I can write other utilities to make this happen. If there is a wierd way of getting

Performance testing best practices when doing TDD?

感情迁移 提交于 2019-12-03 09:39:06
问题 I'm working on a project which is in serious need of some performance tuning. How do I write a test that fails if my optimizations do not in improve the speed of the program? To elaborate a bit: The problem is not discovering which parts to optimize. I can use various profiling and benchmarking tools for that. The problem is using automated tests to document that a specific optimization did indeed have the intended effect. It would also be highly desirable if I could use the test suite to

ASP.NET MVC - Unit testing overkill? (TDD)

半世苍凉 提交于 2019-12-03 08:51:05
问题 So I'm starting to catch the TDD bug but I'm wondering if I'm really doing it right... I seem to be writing A LOT of tests. The more tests the better, sure, but I've got a feeling that I'm over doing it. And to be honest, I don't know how long I can keep up writing these simple repetitive tests. For instance, these are the LogOn actions from my AccountController: public ActionResult LogOn(string returnUrl) { if (string.IsNullOrEmpty(returnUrl)) returnUrl = "/"; var viewModel = new LogOnForm()

How do I unit test the methods in a method object?

非 Y 不嫁゛ 提交于 2019-12-03 07:46:01
I've performed the " Replace Method with Method Object " refactoring described by Beck . Now, I have a class with a "run()" method and a bunch of member functions that decompose the computation into smaller units. How do I test those member functions? My first idea is that my unit tests be basically copies of the "run()" method (with different initializations), but with assertions between each call to the member functions to check the state of the computation. (I'm using Python and the unittest module.) class Train: def __init__(self, options, points): self._options = options self._points =

Why should I use Test Driven Development? [duplicate]

微笑、不失礼 提交于 2019-12-03 07:36:13
问题 This question already has answers here : Closed 10 years ago . Duplicate: Why should I practice Test Driven Development and how should I start? For a developer that doesn't know about Test-Driven Development, what problem(s) will be solved by adopting TDD? [EDIT] Let's assume that the developer already (ab)uses a unit testing framework. 回答1: Here are three reasons that TDD might help a developer/team: Better understanding of what you're going to write Enforces the policy of writing tests a

Best practices for HttpContext and testable controllers in ASP.Net MVC

為{幸葍}努か 提交于 2019-12-03 07:32:31
问题 Update: Based on a couple of the answers I have received, I just want to make clear that I am well aware how to go about mocking HttpContext using a mocking framework. I am more interested knowing what the pros and cons of mocking HttpContext are when compared to using wrapper classes around HttpContext. I'm looking for opinions on how to deal with HttpContext when building testable controllers in ASP.Net MVC. After reading up on it there seems to be two schools of thought - either build off

C# Extension method for checking attributes

偶尔善良 提交于 2019-12-03 07:24:57
问题 Sorry if this is a stupid noob question please be gentle with me I'm trying to learn... I want to test against the attribute methods of things like models and controllers. Mostly to make sure they have the right attrbute ie Required. But i'm also using this as an experiment with extension methods and Lambdas. What I'd like is a method that when implimented looks some thing like Controller controller = new Controller(); controller.MethodName(params).HasAttribute<AttributeName>(); Iveused

Unit Testing Methods With File IO

谁说我不能喝 提交于 2019-12-03 07:21:11
I'm trying to get into the habit of writing unit tests, I've written a few before but they've usually been quite basic...I'd like to start making a move to TDD as i want to improve the quality of my code (design and structure) - reducing coupling, while at the same time hopefully reduce number of regressions which slip through to a testable build. I have taken a relatively simple project i work on to begin with. The resultant program watches a folder and then acts on files within this folder. Here is a typical example of some code extracted from the project: private string RestoreExtension

How to (unit-)test data intensive PL/SQL application

我怕爱的太早我们不能终老 提交于 2019-12-03 07:07:35
问题 Our team is willing to unit-test a new code written under a running project extending an existing huge Oracle system. The system is written solely in PL/SQL, consists of thousands of tables, hundreds of stored procedures packages, mostly getting data from tables and/or inserting/updating other data. Our extension is not an exception. Most functions return data from a quite complex SELECT statementa over many mutually bound tables (with a little added logic before returning them) or make