Showing posts with label testing. Show all posts
Showing posts with label testing. Show all posts

Friday, April 21, 2017

org.openqa.selenium.WebDriverException: cannot get automation extension

In our current project, we write CI tests using Selenium. But several weeks has passed since I wrote a new test and there goes a nice exception while running the old ones.

  
org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension

Doesn't explain much, right?
I find the solution in upgrading my chrome driver.

Wednesday, July 17, 2013

java.lang.illegalstateexception: missing behavior definition for the preceding method call

I have the following exception while mocking a final method with PowerMock.

java.lang.illegalStateException: missing behavior definition for the preceding method call


My previous code was:


 ReloadableResourceBundleMessageSource mockMessage =
createMock(ReloadableResourceBundleMessageSource.class);
        expect(mockMessage.getMessage("text",
null, Locale.ENGLISH)).andReturn("error_message");
 replay(mockMessage);


Then I realized that createMock() and replay() belongs to EasyMock not PowerMock.
I explicitly did these calls:

 ReloadableResourceBundleMessageSource mockMessage =
PowerMock.createMock(ReloadableResourceBundleMessageSource .class);
        expect(mockMessage.getMessage("text",
null, Locale.ENGLISH)).andReturn("error_message");
        PowerMock.replay(mockMessage);


But that's not enough. For PowerMock to work, you'll also need to add few annotations before the class definition.


@RunWith(PowerMockRunner.class)
@PrepareForTest(ReloadableResourceBundleMessageSource.class)

Notice that @PrepareForTest can also be defined just before the test method.
After these fixes my test begins to work.

Friday, July 15, 2011

mockito tutorial video

I recently find a very good screencast about mockito, a great mocking framework. There it is in three parts:






Thursday, December 17, 2009

mockito tutorial

Mockito makes life easier for anyone who's writing unit tests. First I planned writing a brief tutorial for Mockito but then I saw Brett L. Schuchert's mockito tutorial. It is as detailed and clear as it can be. I recommend it.