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

Experiment new design for integration tests. #1399

Closed
wants to merge 3 commits into from

Conversation

sbernard31
Copy link
Contributor

This aims to propose new design for integration tests to allow us to launch tests with different transport layer implementation.

See RegistrationTest2 to see what it looks like.

// Check client is not registered
client = givenClient.build();
assertThat(client).isNotRegisteredAt(server);

// Start it and wait for registration
client.start();
server.waitForNewRegistrationOf(client);
client.waitForRegistrationTo(server);

// Check client is well registered
assertThat(client).isRegisteredAt(server);
Registration registration = server.getRegistrationFor(client);
assertThat(registration.getObjectLinks()) //
        .isEqualTo(linkParser.parseCoreLinkFormat(
                "</>;rt=\"oma.lwm2m\";ct=\"60 110 112 1542 1543 11542 11543\",</1>;ver=1.1,</1/0>,</2>,</3>;ver=1.1,</3/0>,</3442/0>"
                        .getBytes()));

// Check for update
client.waitForUpdateTo(server, LIFETIME, TimeUnit.SECONDS);
server.waitForUpdateOf(registration);
assertThat(client).isRegisteredAt(server);

// Check deregistration
client.stop(true);
server.waitForDeregistrationOf(registration);
assertThat(client).isNotRegisteredAt(server);

I used :

  • AssertJ : to write more elegant assertion (see LeshanTestClientAssert)
  • Mockito : to verify listener call (see waitFor** methods in LeshanTestClient and LeshanTestServer

I also use a kind of Junit5 HACK to be able to use parameter in @BeforeEach, See junit-team/junit5#3157 for more details.

@sbernard31
Copy link
Contributor Author

Exploring class-level parameterization feature discussion (junit-team/junit5#878) at Junit5 repo, I found more workaround for this missing feature. (See junit-team/junit5#3157 (comment))
I created 2 more commit to tests those solutions but not so good to me, I feel the first I tried is the better one 😬 ...

So I plan to start to migrate some tests using this way.
(Stop me if you think I go in a bad direction :grin)

@sbernard31 sbernard31 mentioned this pull request Feb 23, 2023
4 tasks
@sbernard31
Copy link
Contributor Author

sbernard31 commented Feb 28, 2023

(I moved forward about that in parameterize_integration_test branch)

@sbernard31
Copy link
Contributor Author

The first way to parameterized tests are integrated in #1425.

@sbernard31 sbernard31 closed this Apr 5, 2023
@sbernard31 sbernard31 deleted the test_integration_refactoring branch May 12, 2023 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant