Open Malian opened 5 years ago
All tests are correct, but they do different types of testing.
The V4 test looks like Functional Test. It tests the whole functionality of all 3 classes 🙂
I think V3 is the best as Unit Test. It focuses only on the behavior of tested class 🙂
Hi ! I am new to phpspec/prophecy ecosystem and I encounter troubles to write a "simple" test.
I designed a
Timesheet
object that owns severalOccupations
. These occupations are instancied inside a method of theTimesheet
object;fillOccupation
. I would like to design aCounter
that count occupations that take place in the morning (This is for the example purpose but it is not so far from my real use case).My objects:
I would like to test my
Counter
service. I wrote 4 tests to describe the same behavior. These test are green but I do not know what is the recommended way to write a test in this case.Could you please help me to understand the phpspec way to write a test ? When do I need to use a mock? When do I need to instantiate my object ?
Thank you!