In the karate project I am trying I have used karate's ability to assert database entries. And I was looking for a way to insert SQL scripts as a 'given' inside the test rather than calling a java class. Did not see any example in the demo project of karate. What would be the ideal way to do this?
            Asked
            
        
        
            Active
            
        
            Viewed 1,387 times
        
    1 Answers
2
            
            
        If you have already seen the JDBC demo and still feel that is too complicated, then I'm sorry - look for another framework :)
Also see this example if it helps: https://twitter.com/KarateDSL/status/1144458169822806016
And the whole Given When Then approach is over-rated, see: https://stackoverflow.com/a/47799207/143475
        Peter Thomas
        
- 54,465
 - 21
 - 84
 - 248
 
- 
                    I never mentioned that it's complicated. I just didn't find an example with sql insertion as a prerequisite and wanted to know if there's an ideal way of doing the insertion. – Niron Rasanjana Perera Sep 04 '19 at 12:50
 - 
                    @NironRasanjanaPerera you said "rather than calling a java class" which is the same thing. anyway, lets assume I have no idea what you mean by "as a 'given'" and please assume that there is no better way. and by the way please stop the twitter reminders, there is no need – Peter Thomas Sep 04 '19 at 12:54
 - 
                    Sorry about that and I think you have misunderstood the question. I was not asking for a better way. In the demo project you have done database assertions within test. I was asking for a way to insert the data to the db like that. – Niron Rasanjana Perera Sep 04 '19 at 12:59
 - 
                    @NironRasanjanaPerera think hard and then answer this question - do you really think what you are asking is a "Karate" question or a "SQL" question. and why don't you do a search here for Karate and JDBC and see what you find: https://stackoverflow.com/a/51996544/143475 – Peter Thomas Sep 04 '19 at 13:04
 - 
                    I did not see this question and seems like it is the same question I have. Anyway thanks I will work on it. – Niron Rasanjana Perera Sep 04 '19 at 17:38