move TEST_CASE and SOURCE_METHOD to TestableTool class and bump to v0.1.1

This commit is contained in:
金戟
2020-10-20 22:47:25 +08:00
parent d9a7e91b65
commit 379eabc791
10 changed files with 24 additions and 12 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.alibaba.testable</groupId>
<artifactId>agent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>testable-agent</name>

View File

@@ -14,6 +14,7 @@ import java.util.Map;
*/
public class TestClassHandler extends BaseClassHandler {
private static final String CLASS_TESTABLE_TOOL = "com/alibaba/testable/core/tool/TestableTool";
private static final String CLASS_TESTABLE_UTIL = "com/alibaba/testable/core/util/TestableUtil";
private static final String FIELD_TEST_CASE = "TEST_CASE";
private static final String FIELD_SOURCE_METHOD = "SOURCE_METHOD";
@@ -75,7 +76,7 @@ public class TestClassHandler extends BaseClassHandler {
}
private boolean isTestableUtilField(FieldInsnNode fieldInsnNode) {
return fieldInsnNode.owner.equals(CLASS_TESTABLE_UTIL) &&
return fieldInsnNode.owner.equals(CLASS_TESTABLE_TOOL) &&
(fieldInsnNode.name.equals(FIELD_TEST_CASE) || fieldInsnNode.name.equals(FIELD_SOURCE_METHOD));
}

View File

@@ -7,7 +7,7 @@
<description>Unit test enhancement toolkit</description>
<groupId>com.alibaba.testable</groupId>
<artifactId>core</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.1-SNAPSHOT</version>
<name>testable-core</name>
<properties>

View File

@@ -0,0 +1,11 @@
package com.alibaba.testable.core.tool;
/**
* @author flin
*/
public class TestableTool {
public static String TEST_CASE;
public static String SOURCE_METHOD;
}

View File

@@ -7,9 +7,6 @@ import com.alibaba.testable.core.constant.ConstPool;
*/
public class TestableUtil {
public static String TEST_CASE;
public static String SOURCE_METHOD;
public static String currentSourceMethodName(Object testClassRef) {
Class<?> testClass = testClassRef.getClass();
StackTraceElement[] stack = getMainThread().getStackTrace();

View File

@@ -16,7 +16,7 @@
<properties>
<java.version>1.8</java.version>
<testable.version>0.1.0-SNAPSHOT</testable.version>
<testable.version>0.1.1-SNAPSHOT</testable.version>
</properties>
<dependencies>

View File

@@ -7,8 +7,8 @@ import org.junit.jupiter.api.Test;
import java.util.concurrent.Callable;
import static com.alibaba.testable.core.util.TestableUtil.SOURCE_METHOD;
import static com.alibaba.testable.core.util.TestableUtil.TEST_CASE;
import static com.alibaba.testable.core.tool.TestableTool.SOURCE_METHOD;
import static com.alibaba.testable.core.tool.TestableTool.TEST_CASE;
import static org.junit.jupiter.api.Assertions.assertEquals;
@EnableTestable

View File

@@ -17,7 +17,7 @@
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.3.72</kotlin.version>
<testable.version>0.1.0-SNAPSHOT</testable.version>
<testable.version>0.1.1-SNAPSHOT</testable.version>
</properties>
<dependencies>

View File

@@ -3,8 +3,8 @@ package com.alibaba.testable.demo
import com.alibaba.testable.core.accessor.PrivateAccessor
import com.alibaba.testable.core.annotation.EnableTestable
import com.alibaba.testable.core.annotation.TestableInject
import com.alibaba.testable.core.util.TestableUtil.SOURCE_METHOD
import com.alibaba.testable.core.util.TestableUtil.TEST_CASE
import com.alibaba.testable.core.tool.TestableTool.SOURCE_METHOD
import com.alibaba.testable.core.tool.TestableTool.TEST_CASE
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.util.concurrent.Callable

View File

@@ -1,5 +1,8 @@
# Release Note
## v0.1.1
- use `TestableTool` class to expose test context
## v0.1.0
- move generated agent jar to class folder
- now support mock method of any object