Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

avishi-rathore commented Oct 24, 2021

Does this really work?

@stefanbirkner
Copy link
Author

stefanbirkner commented Oct 24, 2021

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