Using sql query results as expected values in FitNesse decision table

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
Is there a way to use the results of a database query as expected results
in a decision table?  For example,  I have following decision table.

|Code                     |ChargeNumber  |ChargeNumberDescription       |
|BER                      |F0000000000000|${BER}                        |
|FAM                      |T0000000000000|${FAM}                        |
|HOL                      |F0000000000000|${HOL}                        |

Can I use a query to get this data from database and use the results in the
decision table instead of hardcoding the expected values?

Thanks.

Jacob.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
Hi Jacob,

Why do you need to do it this way?

this approch is normally bad style.
It's better to define and setup the inital state of your system and then you know exactly what will be the expected result.

Nevertheless you can use jdbcslim to get values from a database and compare them with actual values.
Maybe this is helpful for your scenario.


Search for JdbcSlim.UserGuide.2KeyBenefits.2TestingOnSideEffects in the below

https://rawgit.com/six42/jdbcslim/master/JdbcSlim.htm

https://github.com/six42/jdbcslim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
Thanks for the response. I get the values from a REST API which queries a
database. These values in database have an expiration date. So my test
fails because sometimes I have some expired values in my expected data. I
want to make it dynamic and search the database and use the results as
expected values.

Jacob
On Tue, Jul 18, 2017 at 5:21 PM six42 [hidden email] [fitnesse] <
[hidden email]> wrote:

>
>
> Hi Jacob,
>
> Why do you need to do it this way?
>
> this approch is normally bad style.
> It's better to define and setup the inital state of your system and then
> you know exactly what will be the expected result.
>
> Nevertheless you can use jdbcslim to get values from a database and
> compare them with actual values.
> Maybe this is helpful for your scenario.
>
>
> Search for JdbcSlim.UserGuide.2KeyBenefits.2TestingOnSideEffects in the
> below
>
> https://rawgit.com/six42/jdbcslim/master/JdbcSlim.htm
>
> https://github.com/six42/jdbcslim
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
What works in such a scenario:

Use jdbcSlim to update the expiration date in your database before you call the rest API.

Then your expected results stay static.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
In reply to this post by FitNesse mailing list
Jacob,

 Instead of trying to assert a dynamic result set, consider inserting the expected values into the database in the SetUp of the test, and assert the known set of values.  To work around the expiration date (and even test that feature) you could use a date widget to insert a relative date (looks like the hsac-fitnesse-plugin https://github.com/fhoeben/hsac-fitnesse-plugin does this these days).  By controlling the environment your test will be less brittle, but this may also require a build that tears down and sets up the database.  You could perhaps use a lightweight in-memory database such as H2 http://www.h2database.com, or you could mock out the database response entirely.
 

 Hope this helps,
 Tim Andersen
 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
Thanks for the feedback. Right now I am not using advanced features of
Fitnesse and don't know how to do it. But I will do some research and see
if I could build a temp table in memory to do this

Thanks

Jacob
On Thu, Jul 27, 2017 at 10:02 PM [hidden email] [fitnesse] <
[hidden email]> wrote:

>
>
> Jacob,
>
> Instead of trying to assert a dynamic result set, consider inserting the
> expected values into the database in the SetUp of the test, and assert the
> known set of values.  To work around the expiration date (and even test
> that feature) you could use a date widget to insert a relative date (looks
> like the hsac-fitnesse-plugin
> <https://github.com/fhoeben/hsac-fitnesse-plugin> does this these days).
> By controlling the environment your test will be less brittle, but this may
> also require a build that tears down and sets up the database.  You could
> perhaps use a lightweight in-memory database such as H2
> <http://www.h2database.com>, or you could mock out the database response
> entirely.
>
> Hope this helps,
> Tim Andersen
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
Hi Jacob,

If you can convert your REST result into a List<List<String>> structure
And you run your database query with jdbcSlim than you can compare the two results as outlined here

https://github.com/six42/jdbcslim/blob/master/FitNesseRoot/PlugIns/JdbcSlim/UserGuide/2KeyBenefits/2TestingOnSideEffects.wiki
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using sql query results as expected values in FitNesse decision table

FitNesse mailing list
Thanks.  I think this is what I was looking for.  I will take a look at it.

Jacob.

On Thu, Aug 3, 2017 at 3:14 AM, six42 [hidden email] [fitnesse] <
[hidden email]> wrote:

>
>
> Hi Jacob,
>
> If you can convert your REST result into a List<List<String>> structure
> And you run your database query with jdbcSlim than you can compare the two
> results as outlined here
>
> https://github.com/six42/jdbcslim/blob/master/
> FitNesseRoot/PlugIns/JdbcSlim/UserGuide/2KeyBenefits/
> 2TestingOnSideEffects.wiki
>
>
Loading...