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
Testing with Either #80
Comments
I use equatable package, so two objects being compared by the value it holds on, instead of the instance. This code below will return true: |
I have the very same problem.
output:
|
Hi @LittleFireflies and @Babwenbiber! This looks like a duplicate of #39 and #45 . Basically, Dart
See the linked tickets for some alternative solutions! |
Ok, well noted @spebbe. Thanks for answering. So it's because of the naked list. I'm curious, is it possible to add |
In the context of tests, it might be possible to write custom matchers that would check for deep list equality in more cases. For general code, even if changing the semantics of |
Well then. I'll use |
Cool! @LittleFireflies, if you haven't already seen it, the |
I wrote a package to simplify testing with dartz. It currently works for Options and Eithers. If your class overrides ==, you can use the test('gets the root user', (){
Either<ApiFailure, User> result = getRootUser();
final expectedUser = User(username='root'); // User class overrides ==
expect(result, isRightOf(expectedUser));
}); If your object does not overrides == : test('Test list equality',(){
final object1 = ['foo'];
final object2 = ['foo'];
expect(object1, equals(object2));
}); // test successful For cases like this, and more generic ones, we have the matcher test('Test list equality in either',(){
final object1 = ['foo'];
Either either = Right(object1);
expect(either, isRightThat(equals(['foo'])));
}); // test successful The package also includes matchers for the Option type. |
Hi, I'm currently working on a clean architecture project using Flutter.
I find dartz package is useful to bring either success or failure values.
But, i have issues when it comes to testing.
This is is my test case which won't passed:
Those test will return as follows:
But, somehow it passed when I put both value in the same variable.
I think it is because i create 2 difference instance for the test. Is there a way to evaluate only the value of either instead of comparing the instance?
The text was updated successfully, but these errors were encountered: