Closed AtiyahElsheikh closed 2 years ago
When I start to conduct unit testing, I get the following:
Type Person: Error During Test at /home/atiyah/work/julia/LoneParentsModel.jl/tests/RunTests.jl:67
Got exception outside of a @test
MethodError: no method matching setParent!(::KinshipM.Kinship{Person}, ::typeof(KinshipM.father))
Closest candidates are:
setParent!(::KinshipM.Kinship{P}, ::Union{Nothing, P}) where P at ~/work/julia/LoneParentsModel.jl/src/agents/KinshipM.jl:30
setParent!(::Person, ::Any...) at ~/.julia/packages/TypedDelegation/nCjkv/src/TypedDelegation.jl:207
Stacktrace:
[1] setParent!(a::Person, args::Function)
@ XAgents ~/.julia/packages/TypedDelegation/nCjkv/src/TypedDelegation.jl:207
[2] setAsParentChild!(child::Person, parent::Person)
@ XAgents ~/work/julia/LoneParentsModel.jl/src/agents/Person.jl:115
Strangely, the help functions father, partner, mother
etc. are conflicting with field names of structs.
I would try to change the help functions to fatherOf, motherOf, etc.
father
etc. should not conflict with struct members. Can you maybe send me your unit test?
Ok, I see the problem now:
Yep, forgot to change the variable name, should be parent
.
It includes the following statement
setParent!(child, father) # father is not defined
RunTests.jl needs to be modified to detect such bugs.