tdd

Static Methods : When and when not

橙三吉。 提交于 2019-12-01 00:36:25
问题 I am new to TDD and DDD and I have one simple question regarding static methods in general. Most of the gurus of TDD says in one word that static methods are bad (and that we should forget about creating tons of static utilities that we (um or I) used to make before as they are not testable. I can see why they are not testable ( a great clarification article can be found here for those who are interested but I guess I am the only noob here :( ) but I was wondering is there a nice and clean

Android TDD: The saga continues with Robolectric & Gradle

戏子无情 提交于 2019-12-01 00:28:23
Just when I'd achieved an effective development and build environment with the android-maven-plugin , the new kid on the block, Gradle, starts making inroads into the Android circles. Not being hot on Groovy and with the android-gradle plugin almost as fragmented as the OS itself I've hit some issues. Specifically around building library projects, with flavours and our buddy Robolectric . Short version I am at a loss as to what my next move should be upon encountering the gradle error; Cannot add a SourceSet with name 'testDebug' as a SourceSet with that name already exists. The error emanates

TDD. When you can move on?

二次信任 提交于 2019-11-30 22:41:25
问题 When doing TDD, how to tell "that's enough tests for this class / feature"? I.e. when could you tell that you completed testing all edge cases? 回答1: With Test Driven Development, you’ll write a test before you write the code it tests. Once you’re written the code and the test passes, then it’s time to write another test. If you follow TDD correctly, you’ve written enough tests once you’re code does all that is required. As for edge cases, let's take an example such as validating a parameter

SEH exception with code 0xc0000005 thrown in the test body

[亡魂溺海] 提交于 2019-11-30 22:27:19
问题 I am writing a test using GoogleTest for the following class and I am getting the above error. class Base { // Other Functions; CSig objSig[50]; } The Class CSig is as follows: class CSig { //... constructor, destructor(empty) and some functions CMod *objMod; CDemod *objDemod; } CSig :: CSig { bIsInitialised = false; for (int i=0; i<MAX_NUM; i++) { PStrokePrev[i] = 0.0; } } However, when I discard CSig objSig[50] , the tests run fine. What can I do to solve this issue? Also, I need to have

How do I use Rhino.Mocks to mock a ControllerContext

半腔热情 提交于 2019-11-30 21:59:21
I am trying to use Rhino.Mocks to mock up a ControllerContext object to gain access to runtime objects like User, Request, Response, and Session in my controller unit tests. I've written the below method in an attempt to mock up a controller. private TestController CreateTestControllerAs(string userName) { var mock = MockRepository.GenerateStub<ControllerContext>(); mock.Stub(con => con.HttpContext.User.Identity.Name).Return(userName); mock.Stub(con => con.HttpContext.Request.IsAuthenticated).Return(true); var controller = CreateTestController(); // left out of example for brevity controller

railstutorial.org, Chapter 6. unknown attribute: password

假装没事ソ 提交于 2019-11-30 21:09:15
I have finished Chapter 6 of railstutorial but all my User model specs have started failing soon after I added password & password_confirmation with the following errors: Failures: 1) User Failure/Error: @user = User.new(name: "Example User", email: "user@example.com", ActiveRecord::UnknownAttributeError: unknown attribute: password # ./spec/models/user_spec.rb:17:in `new' # ./spec/models/user_spec.rb:17:in `block (2 levels) in <top (required)>' 2) User Failure/Error: @user = User.new(name: "Example User", email: "user@example.com", ActiveRecord::UnknownAttributeError: unknown attribute:

How to deal with the test data in Junit?

佐手、 提交于 2019-11-30 20:53:37
In TDD(Test Driven Development) development process, how to deal with the test data? Assumption that a scenario, parse a log file to get the needed column. For a strong test, How do I prepare the test data? And is it properly for me locate such files to the test class files? Maven, for example, uses a convention for folder structures that takes care of test data: src main java <-- java source files of main application resources <-- resource files for application (logger config, etc) test java <-- test suites and classes resources <-- additional resources for testing If you use maven for

TDD - One test at a time or make a batch?

萝らか妹 提交于 2019-11-30 20:24:07
For unit tests should you; Write a test. Write code to pass it. Refactor. Or Write all your known tests. Make one pass. Refactor. I ask this because TDD states you stop writing code after all tests pass but this point is unclear. Edit One thing I think TDD focuses on more for this "rule" is in relation to stories/tasks no? Does anyone agree? A few months later A routine I've gotten into after seeing a screencast (I'll try and find the link) on the subject is as follows. Write the names of the tests/behaviour/functionality at the top of the test class. Cut and paste the test name. Complete the

In F# how do you pass a collection to xUnit's InlineData attribute

江枫思渺然 提交于 2019-11-30 20:09:40
I would like to be about to use a list, array, and/or seq as a parameter to xUnit's InlineData. In C# I can do this: using Xunit; //2.1.0 namespace CsTests { public class Tests { [Theory] [InlineData(new[] {1, 2})] public void GivenCollectionItMustPassItToTest(int[] coll) { Assert.Equal(coll, coll); } } } In F# I have this: namespace XunitTests module Tests = open Xunit //2.1.0 [<Theory>] [<InlineData(8)>] [<InlineData(42)>] let ``given a value it must give it to the test`` (value : int) = Assert.Equal(value, value) [<Theory>] [<InlineData([1; 2])>] let ``given a list it should be able to pass

Writing an OS for Motorola 68K processor. Can I emulate it? And can I test-drive OS development?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 19:01:51
Next term, I'll need to write a basic operating system for Motorola 68K processor as part of a course lab material. Is there a Linux emulator of a basic hardware setup with that processor? So my partners and I can debug quicker on our computers instead of physically restarting the board and stuff. Is it possible to apply test-driven development technique to OS development? Code will be mostly assembly and C. What will be the main difficulties with trying to test-drive this? Any advice on how to do it? You certainly can tdd this project. First off decouple all accesses to the hardware with