Open Link184 opened 1 week ago
Is it achievable?
Not 100% sure. But: The ask makes sense - I will look into it.
This seems like a good fit for AOP-based solution. Conversely speaking: I'm not convinced that this is something that Skippy should try to solve.
Example using AspectJ's @DeclareMixin:
build.gradle
:
plugins {
...
id "io.freefair.aspectj.post-compile-weaving" version "8.6"
}
dependencies {
...
implementation 'org.aspectj:aspectjrt:1.9.9'
runtimeOnly 'org.aspectj:aspectjweaver:1.9.9'
}
src/test/java/SkippyAspect.java
:
package com.example;
import io.skippy.junit4.Skippy;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.DeclareMixin;
import org.junit.Rule;
import org.junit.rules.TestRule;
@Aspect
public class SkippyAspect {
@DeclareMixin("(*..*Test)")
public static PredictWithSkippy skippyMixin() {
return () -> Skippy.predictWithSkippy();
}
public interface PredictWithSkippy {
@Rule
TestRule getTestRule();
}
}
Disclaimer: The above is not a polished recommendation (since it does not restrict weaving to the test code).
Thoughts on this approach? I definitely want to touch on this in the documentation.
Thoughts on this approach? I definitely want to touch on this in the documentation.
I would consider bytecode manipulations as a last resort solution. Because it is hard to debug, maintain and test. We also can't be 100% sure that it will work on all jvms. In case we decide to use this solution then I would say it is much safer to deliver it as a separate tool(a plugin for a plugin, lol), to not include it in skippy.
Thoughts on this approach? I definitely want to touch on this in the documentation.
I would consider bytecode manipulations as a last resort solution. Because it is hard to debug, maintain and test. We also can't be 100% sure that it will work on all jvms. In case we decide to use this solution then I would say it is much safer to deliver it as a separate tool(a plugin for a plugin, lol), to not include it in skippy.
Yeah, I am definitely not considering to include this in Skippy. That's not a hill I want to die on (and not the right problem for Skippy to solve).
It is a bit annoying to add rules to all the tests we want to cover with skippy, it can be especially painful on big projects that contains thousands of test classes.
We can customize gradle test tasks to ignore tests by overriding gradle
Test
task:Is it achievable?