joel-costigliola / assertj

AssertJ documentation
60 stars 30 forks source link

extracting() does not work with SoftAssertions #18

Closed X-NoNAME closed 9 years ago

X-NoNAME commented 9 years ago

This test is failing:

import java.util.ArrayList;
import java.util.List;
import org.assertj.core.api.SoftAssertions;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
 *
 * @author Ivan (X-NoNAME) Kazakov
 * @mailto mail@x-noname.ru
 */
public class AssertJTesting {

    private SoftAssertions s ;
    List<Humanoid> lva = new ArrayList<>();
    @BeforeMethod
    public void setUp(){
        s = new SoftAssertions();
        lva.add(new Humanoid("one", "oneone"));
        lva.add(new Humanoid("two", "twotwo"));
        lva.add(new Humanoid("three", "threethree"));
    }

    public static class Humanoid{
        private String name;
        private String namename;
        public Humanoid(String name, String namename) {
            this.name = name;
            this.namename = namename;
        }
    }

    @Test
    public void test_1(){
         s.assertThat(lva).extracting("name")
                 .contains("one")
                 .doesNotContain("oneone")
                .doesNotContainNull();
        s.assertAll();
    }

}
X-NoNAME commented 9 years ago

stacktrace:

The following assertion failed:
1) 
Expecting:
 <[ru.omnicomm.test.wstester.trash.AssertJTesting$Humanoid@47eaf55c, ru.omnicomm.test.wstester.trash.AssertJTesting$Humanoid@2c0798bd, ru.omnicomm.test.wstester.trash.AssertJTesting$Humanoid@2e3252]>
to contain:
 <["one"]>
but could not find:
 <["one"]>

org.assertj.core.api.SoftAssertionError
The following assertion failed:
1) 
Expecting:
 <[ru.omnicomm.test.wstester.trash.AssertJTesting$Humanoid@47eaf55c, ru.omnicomm.test.wstester.trash.AssertJTesting$Humanoid@2c0798bd, ru.omnicomm.test.wstester.trash.AssertJTesting$Humanoid@2e3252]>
to contain:
 <["one"]>
but could not find:
 <["one"]>
    at org.assertj.core.api.SoftAssertions.assertAll(SoftAssertions.java:139)
    at ru.omnicomm.test.wstester.trash.AssertJTesting.test_1(AssertJTesting.java:54)
joel-costigliola commented 9 years ago

Wrong github project, this is assertj website - fill an assertj-core issue. Which version are you using ? Try with 2.0 if it wasn't 2.0

Thanks !

X-NoNAME commented 9 years ago

sorry. version 2.0.0 is fine. thank you.