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

TestCase mutable properties display issue #481

Open
cdibbs opened this issue Sep 9, 2018 · 2 comments
Open

TestCase mutable properties display issue #481

cdibbs opened this issue Sep 9, 2018 · 2 comments
Labels

Comments

@cdibbs
Copy link

cdibbs commented Sep 9, 2018

As of 2.3.0, a test whose TestCase contains an object that gets modified during the test run will display the final value of the object, if the test fails. This hinders identification of the failed test case.

import { Test, TestCase, Expect, FocusTests } from "alsatian";

@FocusTests
export class Thingy {
    @TestCase({a: false})
    @Test()
    atest(dict: any) {
        new SomethingToTest().amethod(dict);
        Expect(dict).toBeNull();
    }
}

export class SomethingToTest {
    amethod(dict: any) {
        dict["a"] = true;
    }
}

Results in the output:

# FIXTURE Thingy
not ok 24 atest ( {"a":true} )
...

But, a should be false. An obvious fix/workaround is just to clone the object before sending it into the test/tested method.

@jamesadarich
Copy link
Member

Good spot @cdibbs probably a bit longer standing than 2.3.0 but a bug nonetheless, I'm currently working on a revamp for 3.0.0 and will try and sneak this in too since should be quite easy :) if it's urgent for you though I am of course as always open to PRs 👍

@cdibbs
Copy link
Author

cdibbs commented Sep 9, 2018

Sweet! Can't wait to try it out. This particular issue has been a minor, cosmetic nuisance, so far, but if it bugs me too much, I'll send a PR your way. :-) Thanks!

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

No branches or pull requests

2 participants