tdd

Best way to do TDD in express versions of visual studio(eg VB Express)

时光总嘲笑我的痴心妄想 提交于 2019-11-27 17:47:15
问题 I have been looking in to doing some test driven development for one of the applications that I'm currently writing(OLE wrapper for an OLE object). The only problem is that I am using the express versions of Visual Studio(for now), at the moment I am using VB express but sometimes I use C# express. Is it possible to do TDD in the express versions? If so what are the bast was to go about it? Cheers. EDIT. By the looks of things I will have to buy the full visual studio so that I can do

Best way to create a test database and load fixtures on Symfony 2 WebTestCase?

那年仲夏 提交于 2019-11-27 17:40:42
I have a WebTestCase that executes some basic routes in my application. I want to, on the setUp method of PHPUnit, create a test database identical to my main database, and load fixtures into it. I'm currently doing some workaround and executing some console commands, something like this: class FixturesWebTestCase extends WebTestCase { protected static $application; protected function setUp() { self::runCommand('doctrine:database:create'); self::runCommand('doctrine:schema:update --force'); self::runCommand('doctrine:fixtures:load --purge-with-truncate'); } protected static function runCommand

Using Dependency Injection with Roboguice?

随声附和 提交于 2019-11-27 17:30:52
I'm working on an Android project and I would like to know any recommendations about what's a good architecture to build an android application. I want to use dependency injection using Roboguice and I've been reading about MVVM pattern or MVC pattern ( Android MVVM Design Pattern Examples ). Also I know that roboguice have a pretty cool Context-Based Event's raising and handling feature that could be very testable as the code is decoupled. Any recommendations on a working design pattern? a testable and scalable architecture you have worked with or developed? The Android platform provides a

Unit testing a class that uses a Timer

梦想的初衷 提交于 2019-11-27 17:08:11
问题 I've got a class that has a private member that has for type System.Windows.Forms.Timer . There's also a private method that is being called every time my timer ticks. Is it worth testing the method? (since it's private) How can I test it? (I know I can have my test class inheriting the class I want to test...) Should I be mocking my timer? Because if I have to test a class that uses an internal timer, my tests may take a lot of time to complete, right? edit: Actually, the method has a

Mocking vs. Spying in mocking frameworks

倾然丶 夕夏残阳落幕 提交于 2019-11-27 17:07:20
In mocking frameworks, you can mock an object or spy on it. What's the difference between the two and when would/should I use one over the other? Looking at mockito, for example, I see similar things being done using spies and mocks, but I am unsure as to the distinction between the two. Mock object replace mocked class entirely, returning recorded or default values. You can create mock out of "thin air". This is what is mostly used during unit testing. When spying, you take an existing object and "replace" only some methods. This is useful when you have a huge class and only want to mock

Moq - How to verify that a property value is set via the setter

帅比萌擦擦* 提交于 2019-11-27 17:05:10
问题 Consider this class: public class Content { public virtual bool IsCheckedOut {get; private set;} public virtual void CheckOut() { IsCheckedOut = true; } public virtual void CheckIn() { //Do Nothing for now as demonstrating false positive test. } } The Checkin method is intentionally empty. Now i have a few test methods to verify the status of calling each method. [TestMethod] public void CheckOutSetsCheckedOutStatusToTrue() { Content c = new Content(); c.CheckOut(); Assert.AreEqual(true, c

How to verify that a specific method was not called using Mockito?

假装没事ソ 提交于 2019-11-27 17:00:16
How to verify that a method is not called on an object's dependency? For example: public interface Dependency { void someMethod(); } public class Foo { public bar(final Dependency d) { ... } } With the Foo test: public class FooTest { @Test public void dependencyIsNotCalled() { final Foo foo = new Foo(...); final Dependency dependency = mock(Dependency.class); foo.bar(dependency); **// verify here that someMethod was not called??** } } Brice Even more meaningful : import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; // ... verify(dependency, never()).someMethod();

How to start unit testing or TDD?

若如初见. 提交于 2019-11-27 16:57:12
I read a lot of posts that convinced me I should start writing unit test, I also started to use dependency injection (Unity) for the sake of easier mocking, but I'm still not quite sure on what stage I should start writing the unit tests and mocks, and how or where to start. Would the preferred way be writing the unit tests before the methods as described in the TDD methodology? Is there any different methodology or manner for unit testing? Test first / test after: It should be noted that 'test first' as part of TDD is just as much (if not more) to do with design as it is to do with unit

Unit tests on MVC validation

烂漫一生 提交于 2019-11-27 16:53:34
How can I test that my controller action is putting the correct errors in the ModelState when validating an entity, when I'm using DataAnnotation validation in MVC 2 Preview 1? Some code to illustrate. First, the action: [HttpPost] public ActionResult Index(BlogPost b) { if(ModelState.IsValid) { _blogService.Insert(b); return(View("Success", b)); } return View(b); } And here's a failing unit test that I think should be passing but isn't (using MbUnit & Moq): [Test] public void When_processing_invalid_post_HomeControllerModelState_should_have_at_least_one_error() { // arrange var mockRepository

What is a “Stub”?

耗尽温柔 提交于 2019-11-27 16:49:11
So, carrying on with my new years resolution to get more in to TDD, I am now starting to work more with Rhino Mocks . One thing I am keen to do is to make sure I really grok what I am getting in to, so I wanted to check my understanding of what I have seen so far (and I thought it would be good to get it up here as a resource). What is a "Stub"? Martin Fowler wrote an excellent article on this subject. From that article: Meszaros uses the term Test Double as the generic term for any kind of pretend object used in place of a real object for testing purposes. The name comes from the notion of a