tdd

How do you know what to test when writing unit tests? [closed]

久未见 提交于 2019-11-28 14:55:56
Using C#, I need a class called User that has a username, password, active flag, first name, last name, full name, etc. There should be methods to authenticate and save a user. Do I just write a test for the methods? And do I even need to worry about testing the properties since they are .Net's getter and setters? Rob Cooper Many great responses to this are also on my question: " Beginning TDD - Challenges? Solutions? Recommendations? " May I also recommend taking a look at my blog post (which was partly inspired by my question), I have got some good feedback on that. Namely: I Don’t Know

Disadvantages of Test Driven Development? [closed]

我们两清 提交于 2019-11-28 14:55:35
What do I lose by adopting test driven design? List only negatives; do not list benefits written in a negative form. Adi Several downsides (and I'm not claiming there are no benefits - especially when writing the foundation of a project - it'd save a lot of time at the end): Big time investment. For the simple case you lose about 20% of the actual implementation, but for complicated cases you lose much more. Additional Complexity. For complex cases your test cases are harder to calculate, I'd suggest in cases like that to try and use automatic reference code that will run in parallel in the

Beginning TDD - Challenges? Solutions? Recommendations? [closed]

我怕爱的太早我们不能终老 提交于 2019-11-28 14:55:00
OK, I know there have already been questions about getting started with TDD .. However, I guess I kind of know the general concensus is to just do it , However, I seem to have the following problems getting my head into the game: When working with collections, do will still test for obvious add/remove/inserts successful, even when based on Generics etc where we kind of "know" its going to work? Some tests seem to take forever to implement.. Such as when working with string output, is there a "better" way to go about this sort of thing? (e.g. test the object model before parsing, break parsing

How do I write unit tests in PHP? [closed]

♀尐吖头ヾ 提交于 2019-11-28 14:51:20
问题 I've read everywhere about how great they are, but for some reason I can't seem to figure out how exactly I'm supposed to test something. Could someone perhaps post a piece of example code and how they would test it? If it's not too much trouble :) 回答1: There is a 3rd "framework", which is by far easier to learn - even easier than Simple Test, it's called phpt. A primer can be found here: http://qa.php.net/write-test.php Edit: Just saw your request for sample code. Let's assume you have the

When to use mocking versus faking in C# unit testing?

断了今生、忘了曾经 提交于 2019-11-28 13:50:04
问题 Can anyone come up with guidelines suggesting the ideal scenarios to choose mocking versus faking, i.e., setting up the essentials manually? I am a bit confused with how to approach this situation. 回答1: Well you have a few things you need to sort out. You have two basic things you'll need to know: Nomenclature and Best Practices. First I want to give you a great video resource from a great tester, Roy Osherove: Unit Testing Reviews by Roy Osherove He starts out by saying that he has done some

How do you unit test a unit test? [closed]

前提是你 提交于 2019-11-28 13:48:53
问题 I was watching Rob Connerys webcasts on the MVCStoreFront App, and I noticed he was unit testing even the most mundane things, things like: public Decimal DiscountPrice { get { return this.Price - this.Discount; } } Would have a test like: [TestMethod] public void Test_DiscountPrice { Product p = new Product(); p.Price = 100; p.Discount = 20; Assert.IsEqual(p.DiscountPrice,80); } While, I am all for unit testing, I sometimes wonder if this form of test first development is really beneficial,

What is the purpose of @SmallTest, @MediumTest, and @LargeTest annotations in Android?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 13:43:56
问题 I'm new to Android and I've seen example code using these annotations. For example: @SmallTest public void testStuff() { TouchUtils.tapView(this, anEditTextView); sendKeys("H E L P SPACE M E PERIOD"); assertEquals("help me.", anEditTextView.getText().toString()); } What does that annotation accomplish? 回答1: This blog post explains it best. Basically, it is the following: Small: this test doesn't interact with any file system or network. Medium: Accesses file systems on box which is running

Unit test adoption [closed]

陌路散爱 提交于 2019-11-28 13:12:00
问题 We have tried to introduce unit testing to our current project but it doesn't seem to be working. The extra code seems to have become a maintenance headache as when our internal Framework changes we have to go around and fix any unit tests that hang off it. We have an abstract base class for unit testing our controllers that acts as a template calling into the child classes' abstract method implementations i.e. Framework calls Initialize so our controller classes all have their own Initialize

BDD And Unit Testing

不羁岁月 提交于 2019-11-28 12:10:05
I have been doing TDD and was using it more as unit testing than to drive my design. Recently I have read a lot about BDD; now that I have a better idea about them both, I was trying to figure out how to use BDD and unit testing concurrently. For example I would drive my design using BDD, Dan North style, and lets say I am working on an app and I have a simple spec and I implement it. I have just enough bdd/spec to cover it. Now after I've re-factored it and am happy and it's passed as done for that spec, should I start writing Unit tests to cover all possible inputs, because that's what I did

C# - Asserting two objects are equal in unit tests

我们两清 提交于 2019-11-28 11:57:25
Either using Nunit or Microsoft.VisualStudio.TestTools.UnitTesting. Right now my assertion fails. [TestMethod] public void GivenEmptyBoardExpectEmptyBoard() { var test = new Board(); var input = new Board() { Rows = new List<Row>() { new Row(){Cells = new List<int>(){0,0,0,0}}, new Row(){Cells = new List<int>(){0,0,0,0}}, new Row(){Cells = new List<int>(){0,0,0,0}}, new Row(){Cells = new List<int>(){0,0,0,0}}, } }; var expected = new Board() { Rows = new List<Row>() { new Row(){Cells = new List<int>(){0,0,0,0}}, new Row(){Cells = new List<int>(){0,0,0,0}}, new Row(){Cells = new List<int>(){0,0