Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java alternative for Ruby's vcr?

Is there a java alternative for Ruby's VCR?

As far as I understand, the benefits of using VCR are immense, you can run an "integration test" and record the results, store them some where locally. Now from the next time when you need to run your tests, you can mockup your actual database hits with the data recorded from the first run.

  1. Is there something similar in java world?
  2. If not, what kind of bottlenecks I might face if I try to implement it?

VCR only records HTTP interactions, but can such an approach be done to record, say any kind of database operations/function calls to other team's APIs which I don't need to test, basically this will relieve me from mocking up so many things by automating it.

Here is an example of VCR with Ruby's unit tests:

like image 922
zengr Avatar asked Oct 16 '11 02:10

zengr


2 Answers

Check out betamax. It's a groovy port of VCR. It should work on the JVM with any language, I believe.

As for using a VCR-like library to record/playback DB interactions: Sven Fuchs tried this approach and didn't see much benefit to it.

like image 176
Myron Marston Avatar answered Oct 16 '22 03:10

Myron Marston


Check out anystub. this is java-lib. it allows to record/playback any String get(String... keys) invocations instead of only HTTP trafic.

like image 38
feech Avatar answered Oct 16 '22 04:10

feech