Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

following the "game of life" example, td.verify with _.isEquality #295

Open
lgandecki opened this issue Nov 10, 2017 · 0 comments
Open

following the "game of life" example, td.verify with _.isEquality #295

lgandecki opened this issue Nov 10, 2017 · 0 comments

Comments

@lgandecki
Copy link
Contributor

lgandecki commented Nov 10, 2017

Hello.
I'm trying to follow the game of life discovery testing by Justin Searls , with TypeScript.

I added the second test, without changing the code, and it passes:

test('one generation', () => {
    const seedWorld = new World()
    td.when(generatesSeedWorld.generate()).thenReturn(seedWorld)
    const seedWorldSecond = new World()

    simulatesConway.simulate(1, 1337)

    td.verify(outputsWorld.output(seedWorld))
    td.verify(outputsWorld.output(seedWorldSecond))
  })

Because seedWorld is at this moment exactly the same as seedWorldSecond (although it is not THE SAME one). When I added this.random = Math.random() to World constructor, the test properly failes.
I'm trying to understand the principle behind this kind of testing, which should not be language/framework specific as far as I understand.

How would you write a test like this then, in testdouble? Should I somehow force a different comparison mode? For now for learning purposes I'm going to leave the random there, but "there must be a better way" ;-)

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant