2014-02-10 10:15 GMT+01:00 Sha <[email protected]>:

>
>
> On Thursday, February 6, 2014 11:21:57 PM UTC+5:30, Lukas Eder wrote:
>
>> Hi Shyam,
>>
>> 2014-02-06 12:54 GMT+01:00 Sha <[email protected]>:
>>
>>> Hi Lukas,
>>>   Today  I had given a partial demo of my POC  to my management about
>>> jOOQ. They are quite impressed with features and ease it provides.
>>>
>>
>> That's great news! Thanks for the feedback!
>>
>>
>>> Apart from what I have show, they are interested for MockDataProvider
>>> feature provided by jOOQ.
>>>
>>> It is understood that ,some time back they got some pdf from jOOQ's
>>> providers regarding the Mock data feature which generates the test data
>>> i.e. mock data.
>>>
>>> Can you give any url link or a doc which throws more light on the same
>>> feature and how to implement for my code ?
>>> Not much information is provided in the user guide.
>>>
>>
>> Yes, you're right. There's not much more in the manual (or in the blog)
>> about the MockDataProvider:
>> - http://www.jooq.org/doc/3.2/manual/tools/jdbc-mocking/
>> - http://blog.jooq.org/2013/02/20/easy-mocking-of-your-database/
>>
>> This feature has been originally requested by Aaron Digulla in this
>> thread:
>> - https://groups.google.com/forum/#!msg/jooq-user/
>> OQzuxbqk-w8/MbtmKAnZ2h4J
>>
>> When you mock your database for unit testing, people usually implement
>> all of the JDBC API, which is quite cumbersome. The idea behind the
>> MockDatabase is that you only implement a single method to simulate almost
>> all database interactions.
>>
>
> Not a problem but where I found more about it, for implementation.
>
>>
>> It is currently in a draft version, and there are no high-priority plans
>> to further enhance it, unless we get more real-world use-cases from
>> customers. I'm personally not that big of a fan of unit testing and mocking
>> database interaction, as it is very hard to cover all the complexity.
>> Personally, I prefer to write integration tests against a real test
>> database with actual data.
>>
> It would be helpful for us, if there is any documentation on how to
> implement it. Please share if there is any.
>

Well, the most authoritative information so far is here in the Javadoc:

- http://www.jooq.org/javadoc/latest/org/jooq/tools/jdbc/MockConnection.html
-
http://www.jooq.org/javadoc/latest/org/jooq/tools/jdbc/MockDataProvider.html#execute(org.jooq.tools.jdbc.MockExecuteContext)

Unfortunately, right now, there is not any other documentation.


>
>
>> Let me know if you have any concrete use-cases that you might want to
>> have covered.
>>
>
> As I told  I need to test/debug the individual piece of logic inside a
> stored procedure as it has several independent blocks of logic which
> depends on each other and work as cohesive. For that we need your help to
> make it possible using our jOOQ. Appreciate your help in this direction.
>

I still recommend doing this with integration tests rather than with a mock
connection. Here's the usual workflow:

1. Reset your database to a well-known test state
2. Run the "stored procedure"
3. Verify the expected database state after the procedure

Why? Imagine the following procedure:

1. select some data
2. if some condition then
2.1 insert some data
2.2 else, update some data
3. select some more data and return it from the procedure

If you're creating a mock database, you will have to emulate the whole
if-else branch in 2. in order to produce the correct result in 3. This can
get very difficult even for this simple example. At the same time, doing
this stuff with an integration test is very straight-forward, as the
database will really maintain the state between 1. 2. and 3.

I really cannot recommend proceeding with a mock database for your
use-case. But in the end, that's up to you :-)

Regards,
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to