Skip to content

Commit

Permalink
server: Separate setup and tear down methods in Bookmarks unit tests
Browse files Browse the repository at this point in the history
Until now, before running each individual unit tests, a new experiment would've been
created and all its previous (if any) bookmarks were deleted. Now, using Before annotation, a new
experiment will be created upon running each individual test, and then, using After annotation, all
the data related to the bookmarks will be deleted.

Signed-off-by: Kaveh Shahedi <[email protected]>
  • Loading branch information
kavehshahedi committed Nov 15, 2024
1 parent 0044363 commit 24be672
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.stubs.BookmarkModelStub;
import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.stubs.ExperimentModelStub;
import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.utils.RestServerTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -46,8 +47,7 @@ public class BookmarkManagerServiceTest extends RestServerTest {
private static final String END = "end";

/**
* Setup method to run before each test. Creates a clean experiment and removes all
* existing bookmarks.
* Setup method to run before each test
*/
@Before
public void setUp() {
Expand All @@ -56,8 +56,14 @@ public void setUp() {
CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);
assertNotNull("Experiment should not be null", experiment);
assertNotNull("Experiment UUID should not be null", experiment.getUUID());
}

// Get all existing bookmarks and delete them
/**
* Tear down method to run after each test
*/
@After
public void tearDown() {
// Remove all bookmarks
WebTarget application = getApplicationEndpoint();
WebTarget bookmarkTarget = application.path(EXPERIMENTS)
.path(experiment.getUUID().toString())
Expand Down

0 comments on commit 24be672

Please sign in to comment.