Questions tagged [test-double]
22 questions
11
votes
2 answers
Testing Promises with multiple thens using testdoublejs
I am using testdouble for stubbing calls within my node.js project. This particular function is wrapping a promise and has multiple then calls within the function itself.
function getUser (rethink, username) {
return new Promise((resolve, reject)…

ckross01
- 1,681
- 2
- 17
- 26
5
votes
2 answers
Unit testing cyclomatically complicated but otherwise trivial calculations
Let's say I have a calculator class who primary function is to do the following (this code is simplified to make the discussion easier, please don't comment on the style of it)
double pilingCarpetArea = (hardstandingsRequireRemediation = true) ?…

cedd
- 1,741
- 1
- 21
- 34
4
votes
1 answer
Rspec expect to recieve message with attributes and ignore others
I'm trying to write a spec for a really long time.
I need to test this:
expect(Foo).to receive(:bar).with(some_args)
and everything works just fine if Foo receives bar only once. But it will receive bar several times for sure so that the string…

Ngoral
- 4,215
- 2
- 20
- 37
2
votes
0 answers
Is there a way to tell the instance of CL_OSQL_TEST_ENVIRONMENT to create views from mocked tables?
Is there a way to tell the instance of CL_OSQL_TEST_ENVIRONMENT to create views from mocked tables?
For example I mock the following tables from the ERP system: BSEG and BKPF.
cl_osql_test_environment=>create(
VALUE #(
'BSEG'
'BKPF'
…

Jagger
- 10,350
- 9
- 51
- 93
2
votes
1 answer
Using expectException and a spy in PHPUnit
I'm using PHPUnit ~5.2 and PHP ~7.0.0.
I have a class that wraps a repository, catches the exceptions it throws, calls a logger and then rethrows the exception.
public function storeDonation( Donation $donation ) {
try {
…

Jeroen De Dauw
- 10,321
- 15
- 56
- 79
1
vote
0 answers
Is there a GCP Secrets Manager test double for local development?
I am looking for a locally executable test double (mock/stub/fake etc.) that can be used for replacing the Google Cloud Secrets Manager used by my application. Something like Localstack in case of AWS. This would allow me to start my app locally and…

Esta Nagy
- 219
- 2
- 9
1
vote
2 answers
Unit Testing: Verify that a method was called, without testing frameworks like Mockito or MockK
Not using testing frameworks like MockK or Mockito seems to be becoming more and more popular. I decided to try this approach. So far so good, returning fake data is simple. But how do I verify that a function (that does not return data) has been…

Sermilion
- 1,920
- 3
- 35
- 54
1
vote
0 answers
Why is testDouble not able to mock a 3rd party function?
I have a local module with a function that I want to mock using tetDouble for nodeJS
This is the function that I want to test:
import {supportsAPL} from "skills-lib"
export function example(thing: any): boolean {
if (!supportsAPL(thing)) {
…

linker85
- 1,601
- 5
- 26
- 44
1
vote
1 answer
Is it ok to place test double implementations on the main java code
With regards to test doubles is it ok to place them on the main code so that they can be used, when testing code that contains the original library jar as a dependency?
There is code that assists me on unit testing (test doubles) on a library I…

gkatzioura
- 2,655
- 2
- 26
- 39
1
vote
0 answers
Stub 'require' to throw error using 'testdouble'
I want to stub the 'require' call to a module to throw error. Is there a way to do it using 'testdouble' or 'proxyrequire'?

Lavish
- 11
- 4
1
vote
2 answers
PowerkMock-ing BufferedReader runs interminately
What I want to do is to mock newly created instance of BufferedReader. Here's the code that should be tested:
A.java
...
@Override
public String read(String fileName) throws IOException {
...
try {
fileReader = new…

azizbekian
- 60,783
- 13
- 169
- 249
1
vote
0 answers
Test doubles for Python standard library HTTP classes
What widely-used Python library is there to make test doubles of the behaviour of low-level HTTP APIs from the Python standard library?
I have a code base (Python 2 code) which performs HTTP sessions using the various HTTP-level classes in the…

bignose
- 30,281
- 14
- 77
- 110
0
votes
0 answers
Is a test double programmed to throw exception still a "stub"?
Arguing with my colleague on terminology.
Imagine the following jUnit test:
class PlanetDensityCalculatorTest {
PlanetService planetServiceTestDouble = Mockito.mock(PlanetService.class);
PlanetDensityCalculator calculator = new…

Kirill
- 6,762
- 4
- 51
- 81
0
votes
0 answers
Unit Testing in Android
I am trying to unit test my repository . In that i want to write test for function which makes api calls.(function name :- searchImage)
The function calls datasource for actual api calls.
I am using a fake data source which extends from the shopping…

Shashank Mishra
- 1
- 1
- 2
0
votes
1 answer
Assert equal time with some tolerance in phpunit
I am just starting with phpunit and this is where I have little problem now.
The class I'm writing a test for, has a Logger method which when called, adds the timestamp to a property, Like this:
$this->logger->info('Log created', [
…

Ratin
- 39
- 7