Write Spock test cases for Spring boot application

I am working on spring boot application. I have to write test cases for it. I haven't written test cases before, so someone suggested using spock framework for it. I explored spock and i think it is more related to groovy language.

Can i write spock test cases for my spring application?

If so then could you suggest me a better documentation of "how to use it with spring boot application"?

-------------Problems Reply------------

Yes, you can write spock test cases for your spring application.

Look at the official documentation for an example of Spock testing with Spring Boot

35.3.1 Using Spock to test Spring Boot applications

A simple google search reveals a basic example of Using Spock to test Spring classes.

Spock relies heavily on the Spring's TestContext framework and does this via the @ContextConfiguration annotation. This allows the test specification class to load an application context from one or more locations.

Spring One g2x has a large presentation on Testing Java, Groovy, Spring and Web Applications with Spock.

Groovy and Java can freely be mixed together you can use any Java based library you like, or use Groovy based libraries.

The Spring framework supports Groovy and - not surprisingly - Spring TestContext framework works well with Spock Spock specifications can be run from an IDE just like normal JUnit tests and, last but not least, implementing them is a great opportunity to learn the Groovy language.source

Category:java Views:3 Time:2018-12-28

Related post

  • Sample junit test case for spring mvc with resteasy controller application 2011-05-13

    I'm trying on spring mvc with resteasy test case, already knew spring mvc test case but can't find sample for spring mvc with resteasy test case! If any one knows plz help me, i'm trying it last few days! Thanx in Advance! --------------Solutions----

  • How should you write junit test cases for multiple implementation of the same interface? 2009-01-09

    Before asking question, let me explain the current setup: I have an service interface, say Service, and one implementation, say ServiceImpl. This ServiceImpl uses some other services. All the services are loaded as bean by spring. Now, I want to writ

  • Is it advisable to write a test case for every class in your program? 2011-08-18

    Im am just getting introduced to unit testing and test driven development. Thus far, I have only used Junit as testing framework. A question which emerged and for which I have not yet found a definite answer is: how much test cases do I need to write

  • How to write unit test cases for rake tasks in rails? 2012-02-17

    Hi all I have this situation , I need to write unit test cases for rake tasks in my rails application but i could not figure out a way to do that. Did any one try that ? --------------Solutions------------- What you can do is this.. Write your logic

  • how to write unit test case for controller class using mockito 2012-01-17

    I am very new to Mockito and jUnit and I try to learn the right way to do TDD. I need couples of example so that i can write unit test using mockito Following is my controller class which upload file and perform some action on this file inputs. @Cont

  • How to write a test case for ensuring thread-safe 2010-07-15

    I wrote a thread-safe(at least the aim is that) container class in C++. I lock mutexes while accessing the member and release when finished. Now, I try to write a test case if it is really thread safe. Let's say, I have Container container and two th

  • How to write Unit Test case for Zend Db Table Row 2011-08-29

    I am trying to write test case for my Row classes and I don't really what is the proper way to do that. I've seen many example use model & table, for example http://techportal.inviqa.com/2010/12/07/unit-testing-databases-with-zend-framework/. The

  • Changing default welcome-page for spring-boot application deployed as a war 2014-09-26

    I was trying to find a way to change the default welcome-page for a spring-boot application that is being deployed as a war in production but I can't find a way to do it without a web.xml file. According to the documentation we can do it using the Em

  • Can anybody write the test cases for sticky note? 2011-01-16

    Test cases for manual testing. Step by step procedure to test this functionality(sticky note) so that it gives desired output. --------------Solutions------------- Probably that it sticks, stay stuck for awhile, removable (and doesn't leave residue b

  • How to write a test case for a method returning object 2012-04-06

    I have a method for which the return type is object. How do I create a test case for this? How do I mention that the result should be an object? e.g.: public Expression getFilter(String expo) { // do something return object; } --------------Solutions

  • writing test case for a DAO on a J2ee Application 2009-11-08

    I am trying to write some test cases for my DAO classes in a J2EE applications. Methods in my DAO classes try to get connection to the Database based on a JDBC URL (which is on the app server). So from the front end if I click bunch of stuff and make

  • How to write test cases for the home screen activity using robotium in android 2011-07-26

    I am working on Robotium to write the test cases for one of the Android application. My requirement is to write the test suits for the lock screen and home screen with my test case. But I am unable to get home screen events and lock screen dragging t

  • JUnit test cases for method which may include call to other methods 2010-05-06

    I am new to Junit.I am using JUnit 3.8. My problem is,the methods of my application involve database operations(insert,update,delete...) and also one method may have call to number of other methods. I am hardcoding the input values in the test cases.

  • Unit Test Cases for views/viewcontroller and Delegate functions for iPhone 2010-08-27

    I need to write unit test cases for my views.Using some apple demo projects i learnt how to write a unit test case for simple functions(which includes mathematical logic like GCD,Prime etc). now i need to understand the same for Appdelegates and view

  • File/Registry Test Case for NUnit 2009-11-04

    I am new (as of today) to NUnit and TDD. However, I am very interested in the technique and I am trying to learn. I have a test case I would like to read from a file if it exists, otherwise I will grab from the registry. How do I test both conditions

  • How to write NUNit test cases when data is read from some database? 2010-12-21

    I want to test a functionality which includes a call to web service to get the data from database. The methods then operate on that data. Now I want to write NUnit test cases for those methods. How can I assert results or values when I cannot know (a

  • Create unit test cases for a method which does not return any value in C# 2011-04-28

    Possible Duplicate: Unit testing void methods? I need to write unit test cases for the GUI methods which does not return any value, how i can test the ac --------------Solutions------------- You can make sure it doesn't throw, at least by Assert.Does

  • Apex - SalesForce - Writing Test case for a Trigger 2012-04-04

    Hello Folks, I am really new to Apex Development and currently trying to write a test case for this trigger. Any kinds of help is really appreciated! trigger Milestone1_Expense_Trigger on Milestone1_Expense__c (before insert, before update) { if(Trig

  • Junit Test case for void method which creates a file 2012-04-26

    I have Java program which fetches HTML from a website. It displays the content on console and then saves it to a file named web_content.txt. How do I write a test case for this? My Program is: public class UrlDown { public static void main(String[] a

  • How to write test case for play pause stop functions of mobile using ruby? 2011-04-24

    I know a little about test driven development in ruby but I don't no the logic behind to write test cases for start pause stop functions in ruby. I know asking complete code is not a good behaviour. Can anyone give me a hint from which I can understa

  • How do I write the selenium IDE test case for CAPTCHA images? 2011-08-18

    I am working on Selenium IDE for writing the test cases for a registration form. The registration form has a CAPTCHA image so I am not able to proceed with the automation, What could be the best solution to go ahead with? If I can provide a break poi

  • How to write test cases for complex underlying entity? 2011-11-07

    I am wriring unit test cases for an existing system. The architecture for the underlying classes if very complex in itself. Blockquote RequestHanndler ==> processes ==> Order ===> is dependent on ==> service layer == connected to ==> D

  • How to write test cases for assignment 2012-04-04

    The part of my assignment is to create tests for each function. This ones kinda long but I am so confused. I put a link below this function so you can see how it looks like first code is extremely long because. def load_profiles(profiles_file, person

  • junit test case for a method with hibernate fetch 2012-02-02

    I have a User table and in UserController.java I have a method userList(); which returns all users from database using hibernate. How can I write a JUnit test case for this piece of code. I am new to JUnit`. Please help. public List<User> userL

  • Are the unit test case for JPA worthy? anyway it is just going to access DB, why do we need it? 2009-01-17

    Are the unit test case for JPA worthy? anyway it is just going to access DB, why do we need it? --------------Solutions------------- I disagree with most of the answers so far. For most enterprise applications, much of the business logic is embedded

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.124 (s). 11 q(s)