Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Serialize" to mocking/junit tests #12

Open
mkotsbak opened this issue Jun 7, 2010 · 4 comments
Open

"Serialize" to mocking/junit tests #12

mkotsbak opened this issue Jun 7, 2010 · 4 comments

Comments

@mkotsbak
Copy link
Contributor

mkotsbak commented Jun 7, 2010

Generate code that mocks using some lib instead of the aspectj playback code and verifies the return values/parameter values (most mocking libs supports both sequential return values from mocks (like the lib works now) and based on parameters (see other task).

I think of starting on this task by making a test that checks if a mocking lib is usable (i.e. it can mock invocations without making interfaces/changing existing code).

@mkotsbak
Copy link
Contributor Author

mkotsbak commented Jun 7, 2010

Follow/comment the development of this task here (is there a better way to refer to a branch?):

http://github.com/mkotsbak/jackbox/tree/topic/mocking_serialization

@mkotsbak
Copy link
Contributor Author

mkotsbak commented Jun 7, 2010

Actually according to my tests (see my branch, they run in eclipse) it seems like Powermock has the required properties to be able to mock the method invocations without any change of the legacy code. Combining object creating interception and partial mocks seems to do the job.

It even does not require any special command line to the java command, as the aspectj. Maybe that one or technology it uses can replace the aspects too?

@mkotsbak
Copy link
Contributor Author

mkotsbak commented Jun 7, 2010

I guess it also would be possible to generate and the mock test dynamically using the JMock API (and include annotation @PrepareEverythingForTest somewhere) from the recorded data in e.g. json-format, instead of generating any java code.

@mkotsbak
Copy link
Contributor Author

I have started implementation of this in my branch:

http://github.com/mkotsbak/jackbox/tree/topic/powermock_tests_generation

If somebody know a better lib to generate java code and how to compile the generated code to test it, please let me know. Velocity could be an option I know.

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

No branches or pull requests

1 participant