Skip to content

when().thenReturn() always return nil #367

@alopezh

Description

@alopezh

I'm trying to make getExpositionInfo() to return a value like this

        stub(expositionInfoRepository!) { stub in
            
            let expositionInfo = ExpositionInfo(level: .Healthy)
            when(stub.getExpositionInfo()).thenReturn(expositionInfo)
           
         }

When the call to the stubbed method is done inside the sut it returns nil

I've been debugging and when setting up the return value:

public extension StubFunctionThenReturnTrait {
    @discardableResult
    func thenReturn(_ output: OutputType, _ outputs: OutputType...) -> Self {
        ([output] + outputs).forEach { output in
            stub.appendAction(.returnValue(output))
        }
        return self
    }
}

output parameter is always nil, it look like it's overwrited somewhere.

Is there anything wrong with my code?

Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseA Cuckoo maintainer is awaiting response from the issue/PR author/community.help wantedThis issue is asking for a way to solve a problem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions