Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf-test-support: @Before/AfterMethod/Class support is now in classes
Mixin interfaces are just marker interfaces, explanation there. (cherry picked from commit ff6cbad)
- Loading branch information
Showing
5 changed files
with
101 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 15 additions & 16 deletions
31
.../test-ng/src/main/java/com/evolveum/midpoint/tools/testng/PerformanceTestMethodMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
/* | ||
* Copyright (C) 2010-2020 Evolveum and contributors | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.tools.testng; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
|
||
/** | ||
* Mixin supporting work with {@link TestMonitor} at the method-scope level | ||
* (one test report for each test method). | ||
* Details of setting of {@link TestMonitor} is up to the class, methods from | ||
* {@link PerformanceTestCommonMixin} must be implemented. | ||
* | ||
* [NOTE] | ||
* ==== | ||
* Actual `@Before/AfterMethod` methods are implemented in `AbstractUnitTest` | ||
* and `AbstractSpringTest` using `instanceof` check for two reasons: | ||
* | ||
* * If mixin interface is on the abstract class the lifecycle methods *are not called at all* | ||
* in the test subclasses, which really sucks. | ||
* * To use the same strategy as in {@link PerformanceTestClassMixin} which actually has another | ||
* good reason to do this (issue that does not affect the method lifecycle that much). | ||
* | ||
* So currently this is only marker interface used by lifecycle methods in our two top-level | ||
* classes (unit/Spring) and everything works fine. | ||
* ==== | ||
*/ | ||
public interface PerformanceTestMethodMixin extends PerformanceTestCommonMixin { | ||
|
||
@BeforeMethod | ||
default void initTestMonitor() { | ||
createTestMonitor(); | ||
} | ||
|
||
@AfterMethod | ||
default void dumpReport(Method method) { | ||
dumpReport(getClass().getSimpleName() + "#" + method.getName()); | ||
} | ||
} |