July 2013
Intermediate to advanced
370 pages
8h 27m
English
Suppose we have a class that depends on a method that does some significant work and takes substantial time and resources,
such as the following
myMethod
:
| UnitTestingWithGroovy/com/agiledeveloper/CodeWithHeavierDependencies.groovy | |
| | package com.agiledeveloper |
| | |
| | public class CodeWithHeavierDependencies |
| | { |
| | public void myMethod() |
| | { |
| | def value = someAction() + 10 |
| | |
| | println(value) |
| | } |
| | |
| | int someAction() |
| | { |
| | Thread.sleep(5000) // simulates time consuming action |
| | |
| | return Math.random() * 100 // Simulated result of some action |
| | } |
| | } |
We’re interested in testing
myMethod
(which belongs to CodeWith-HeavierDependencies).
However, the method depends on
someAction , which simulates ...
Read now
Unlock full access