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

Add RM annotations for better UX #19

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.annotations;

import io.skodjob.testframe.listeners.ResourceManagerCleanerExtension;
import io.skodjob.testframe.listeners.ResourceManagerExtension;
import org.junit.jupiter.api.extension.ExtendWith;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(ElementType.TYPE)
@Retention(RUNTIME)
@ExtendWith(ResourceManagerExtension.class)
@ExtendWith(ResourceManagerCleanerExtension.class)
public @interface ResourceManager {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.annotations;

import io.skodjob.testframe.listeners.ResourceManagerExtension;
import org.junit.jupiter.api.extension.ExtendWith;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(ElementType.TYPE)
@Retention(RUNTIME)
@ExtendWith(ResourceManagerExtension.class)
public @interface ResourceManagerDebug {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.annotations;

import io.skodjob.testframe.listeners.TestVisualSeparatorExtension;
import org.junit.jupiter.api.extension.ExtendWith;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(ElementType.TYPE)
@Retention(RUNTIME)
@ExtendWith(TestVisualSeparatorExtension.class)
public @interface TestVisualSeparator {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.skodjob.testframe.listeners;

import io.skodjob.testframe.resources.ResourceManager;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
* jUnit5 specific class which listening on test callbacks
*/
public class ResourceManagerCleanerExtension
implements AfterAllCallback, AfterEachCallback {

@Override
public void afterAll(ExtensionContext extensionContext) {
ResourceManager.setTestContext(extensionContext);
ResourceManager.getInstance().deleteResources();
}

@Override
public void afterEach(ExtensionContext extensionContext) {
ResourceManager.setTestContext(extensionContext);
ResourceManager.getInstance().deleteResources();
}
}
Loading