google mock – can I call EXPECT_CALL multiple times on same mock object?

Yes, you can call EXPECT_CALL on the same mock object multiple times. As long as you assure that all EXPECT_CALL were called before the mocked methods were actually used. Otherwise your test will rely on undefined behavior. From ForDummies: Important note: gMock requires expectations to be set before the mock functions are called, otherwise the … Read more

Mocking and Stubbing with protractor

This blog post discusses advance usage scenarios for Protractor. In particular it covers the the little know addMockModule() method of the Protractor browser object. The method allows you to create angular modules in Protractor (i.e. mocks or stubs of your API module) and upload them to the browser to replace the real implementation within the … Read more

Unit Test Laravel’s FormRequest

I found a good solution on Laracast and added some customization to the mix. The Code /** * Test first_name validation rules * * @return void */ public function test_valid_first_name() { $this->assertTrue($this->validateField(‘first_name’, ‘jon’)); $this->assertTrue($this->validateField(‘first_name’, ‘jo’)); $this->assertFalse($this->validateField(‘first_name’, ‘j’)); $this->assertFalse($this->validateField(‘first_name’, ”)); $this->assertFalse($this->validateField(‘first_name’, ‘1’)); $this->assertFalse($this->validateField(‘first_name’, ‘jon1’)); } /** * Check a field and value against validation rule * … Read more

.NET NUnit test – Assembly.GetEntryAssembly() is null

Implement the SetEntryAssembly(Assembly assembly) method given in http://frostwave.googlecode.com/svn-history/r75/trunk/F2DUnitTests/Code/AssemblyUtilities.cs to your unit test project. /// <summary> /// Use as first line in ad hoc tests (needed by XNA specifically) /// </summary> public static void SetEntryAssembly() { SetEntryAssembly(Assembly.GetCallingAssembly()); } /// <summary> /// Allows setting the Entry Assembly when needed. /// Use AssemblyUtilities.SetEntryAssembly() as first line in XNA … Read more