Rostyslaw
Rostyslaw

Reputation: 33

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

Upvotes: 3

Views: 307

Answers (1)

armandino
armandino

Reputation: 18562

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

Upvotes: 1

Related Questions