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

Contains.Item() fails for collections in NUnit 3.8 #2386

Closed
RalfKoban opened this issue Aug 28, 2017 · 11 comments
Closed

Contains.Item() fails for collections in NUnit 3.8 #2386

RalfKoban opened this issue Aug 28, 2017 · 11 comments

Comments

@RalfKoban
Copy link

Hi,

just updated from NUnit 3.7.1 to 3.8.0.
Now, a test starts to fail consistently which succeeded in the past.

Repro:


        [Test]
        public void Collection_regression_in_380() => Assert.That(new[] { "test", "test2", "test3" }, Contains.Item("test").And.Contains("test2").And.Contains("test3"));

Best regards,
Ralf Koban

@mikkelbu
Copy link
Member

I think this is due to my solution of #1324

@rprouse
Copy link
Member

rprouse commented Aug 28, 2017

@mikkelbu I am hoping to do a hotfix tonight or tomorrow morning. Are you investigating this issue?

@rprouse rprouse added this to the 3.8.1 milestone Aug 28, 2017
@rprouse rprouse self-assigned this Aug 28, 2017
@rprouse
Copy link
Member

rprouse commented Aug 28, 2017

@mikkelbu I am starting to triage this issue. If you have ideas or want to work on it, let me know.

@rprouse
Copy link
Member

rprouse commented Aug 28, 2017

PR is up for this. It was your change @mikkelbu, good catch, but it wasn't your fault, we didn't have any tests for this.

@jnm2
Copy link
Contributor

jnm2 commented Aug 29, 2017

Absolutely. Do not feel strange about making mistakes. It's par for the course. Look what three of us missed: nunit/nunit-console#285 😄

@mikkelbu
Copy link
Member

Great work guys 👍 . I was offline all last night (for once ;)), so I did not look into this, so no time wasted 😄 .

@AzP
Copy link

AzP commented Sep 14, 2017

We're still seeing this issue on 3.8.1. We updated directly from 3.6 to 3.8.1, so we've never had 3.8.0 installed.

@mikkelbu
Copy link
Member

@AzP Are you seeing that the constraint fails (if so can you give an example)? Or that something like the following does not compile?

    [Test]
    public void ContainsItemUsing()
    {
      var collection1 = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8 };
      // DOES NOT COMPILE: There is no Using on SomeItemsConstraint
      var constraint = Contains.Item(7).Using(myIntComparer);
      Assert.That(collection1, constraint);
    }

The problem about Contains.Item(object).Using(...) not compiling anymore can be found here #2412

@AzP
Copy link

AzP commented Sep 14, 2017

The problem we're seeing is that tests that were previously passing are now failing because Has.Member() (or even Has.Member().And.Member()) are not recognizing objects within a list.
The check compiles and does not throw exceptions, it just doesn't recognize that the member is in the collection.

@mikkelbu
Copy link
Member

mikkelbu commented Sep 14, 2017

Ok. Then the issue to watch is #2411 (but #2411 and #2412 are related)

@AzP
Copy link

AzP commented Sep 14, 2017

It seems one of the issues might be caused by using CollectionAssert.Contains(PseudoEnum[], string) where PseudoEnum has implicit comparison functions with strings.
It seems to have handled the implicit cast automatically for 3.6.4, but now the comparison fails.

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

No branches or pull requests

5 participants