Skip to content

Instantly share code, notes, and snippets.

@stefanbirkner
Created July 20, 2011 15:38
Show Gist options
  • Save stefanbirkner/1095194 to your computer and use it in GitHub Desktop.
Save stefanbirkner/1095194 to your computer and use it in GitHub Desktop.
Convert tests from EasyMock to Mockito
#!/bin/bash
fgrep -Rl "EasyMock" testsrc | fgrep -v ".svn" | while read item
do
sed -i 's/org.easymock.EasyMock.createNiceMock/org.mockito.Mockito.mock/g' $item
sed -i 's/org.easymock.EasyMock.createMock/org.mockito.Mockito.mock/g' $item
sed -i 's/org.easymock.EasyMock.expect/org.mockito.Mockito.when/g' $item
sed -i 's/org.easymock.EasyMock/org.mockito.Mockito/g' $item
sed -i 's/EasyMock/Mockito/g' $item
sed -i 's/createNiceMock/mock/g' $item
sed -i 's/createMock/mock/g' $item
sed -i 's/expect(/when(/g' $item
sed -i 's/andReturn/thenReturn/g' $item
sed -i 's/\.anyTimes()//g' $item
sed -i '/replay[^A-Za-z0-9]/d' $item
done
@avishi-rathore
Copy link

Does this really work?

@stefanbirkner
Copy link
Author

It worked back in the times when I used it. Some manual adjustments may be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment