Search code examples
javajunit5instancio

Instancio does not show a test failure message in logs


I was trying to use Instancio for generating data for automated UI testing (filling the registration form with Selenium in particular). So I wrote a simple code like that:

@Test
    public void randomVolunteerRegTest(){
        driver = TestUtilities.getDriver("chrome");
        Volunteer volunteer = Instancio.create(Volunteer.class);
        registrationTest(volunteer);
        Assertions.assertEquals(volunteer.getPassword(), volunteer.getConfirmPassword());
    }

Assertions are made using Junit5

Its obvious that the test is going to fail every time since values compared are always different

But on the official documentation page its written that in the case of test assertion failure the message should be thrown in logs indicating the instance seed used for generating data allowing to reproduce the case. But i dont get one, only this:

org.opentest4j.AssertionFailedError: 
Expected :PLQ
Actual   :RUOYWWDNQ

So im confused why isnt it working, am I doing something wrong?

Tried to receive a log message with seed instance to reproduce a failed test


Solution

  • Do you have @ExtendWith(InstancioExtension.class) on your test class? The extension needs to be declared for the seed to be reported:

    @ExtendWith(InstancioExtension.class)
    class ExampleTest {
    
        @Test
        void example() {
            // ...
        }
    }
    

    Docs: https://www.instancio.org/user-guide/#junit-jupiter-integration