Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By gimbal2

Thread: Effect of calling real service call in test

  1. #1
    anjibman is offline Member
    Join Date
    Dec 2010
    Posts
    48
    Rep Power
    0

    Default Effect of calling real service call in test

    Hi All,

    I am trying to understand the effect of calling real business logic from the test class. If I have a test class that call the service method which make update to DB. Is DB really changes through test class?

    e.g.
    Java Code:
    @Test 
    public void testUpdate() {
       MyDto myDto = new MyDto(paramters to create new myDto object); //creating new dto object  
       myService.updateMyData(myDto); //passing new dto object for update (DB record really changed??)
       MyDto testDto = myRepo.find(myDto.getKey()); //get record for the corresponding key
       assert testDto.getSomeProp() == myDto.getSomeProp(); //what testDto.getSomeProp() return? new value send on myDto or old value from DB?
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Effect of calling real service call in test

    Whatever db your dto is set up to talk to will be changed, unless you've mocked out the connection.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Effect of calling real service call in test

    Just having a @Test annotation on a method is not going to magically change how business logic behaves. It does what it is instructed to do and if that is to launch a nuclear missile, that missile is going to launch.
    Jodokus likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,774
    Blog Entries
    7
    Rep Power
    21

    Default Re: Effect of calling real service call in test

    Quote Originally Posted by gimbal2 View Post
    Just having a @Test annotation on a method is not going to magically change how business logic behaves. It does what it is instructed to do and if that is to launch a nuclear missile, that missile is going to launch.
    That is against the licence agreement for the use of the JVM.

    kind regards,

    Jos (*kaboom*)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. How to call this RESTful service?
    By petal in forum New To Java
    Replies: 1
    Last Post: 08-15-2013, 06:21 PM
  2. 405 error when trying to call web service method
    By Jackson86 in forum Web Frameworks
    Replies: 1
    Last Post: 05-22-2013, 07:39 AM
  3. Call Web Service method through a Proxy
    By Dimis in forum Web Frameworks
    Replies: 0
    Last Post: 11-29-2012, 06:02 PM
  4. how to call service method inside another service
    By kirtichopra2003 in forum Web Frameworks
    Replies: 1
    Last Post: 10-24-2009, 03:19 AM
  5. How to Call a java service
    By omikeneil in forum Advanced Java
    Replies: 3
    Last Post: 10-17-2009, 04:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •