mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-24 11:20:26 +08:00
support mute agent log
This commit is contained in:
parent
9b82fcdc24
commit
d1007f6166
@ -3,7 +3,7 @@
|
||||
## 0.4.2
|
||||
- support change javaagent global log level via maven plugin
|
||||
- fix an issue of duplicate test class injection
|
||||
- fix an issue cause multiple method invocation mock fail
|
||||
- fix an issue cause multiple-line method invocation mock fail
|
||||
|
||||
## 0.4.1
|
||||
- deprecate @TestableMock annotation, use @MockMethod and @MockConstructor instead
|
||||
|
@ -19,11 +19,11 @@
|
||||
</plugin>
|
||||
```
|
||||
|
||||
> 当使用`testable-maven-plugin`插件时,应该移除`maven-surefire-plugin`插件上的TestableMock相关配置,同时可以从项目的`pom.xml`文件中移除对`com.alibaba.testable:testable-agent`包的显示依赖
|
||||
> 当使用`testable-maven-plugin`插件时,应该移除`maven-surefire-plugin`插件上的TestableMock相关配置
|
||||
|
||||
`testable-maven-plugin`插件能够与Jacoco插件直接同时使用,无需额外适配,因此能使`pom.xml`文件编写起来更简单且美观。
|
||||
|
||||
但是,当通过IDE运行单个测试用例时,Mock功能会失效。
|
||||
但需要注意的是,当通过IDE运行单个测试用例时,Mock功能会失效。
|
||||
|
||||
这是由于IDE运行单个测试用例时通常都只会运行`maven-surefire-plugin`插件,跳过了`testable-maven-plugin`插件执行,导致Mock功能所需的JavaAgent没有随测试注入。
|
||||
|
||||
@ -33,4 +33,4 @@
|
||||
|
||||
![idea-vm-option](https://testable-code.oss-cn-beijing.aliyuncs.com/idea-vm-option.png)
|
||||
|
||||
这样实际上还是该了`maven-surefire-plugin`插件的配置,因此目前除了需要考虑美观因素的场景以外,直接在`pom.xml`文件中修改`maven-surefire-plugin`插件配置依然是更加实用的方案。
|
||||
此插件的原理实际上是间接修改`maven-surefire-plugin`的配置,因此除了相对美观以外,并无特别之处。目前而言,直接在`pom.xml`文件中修改`maven-surefire-plugin`插件配置依然是更实用的方案。
|
||||
|
@ -12,6 +12,7 @@ import java.lang.instrument.Instrumentation;
|
||||
public class PreMain {
|
||||
|
||||
private static final String AND = "&";
|
||||
private static final String MUTE = "mute";
|
||||
private static final String DEBUG = "debug";
|
||||
private static final String VERBOSE = "verbose";
|
||||
private static final String LOG_LEVEL = "logLevel";
|
||||
@ -41,7 +42,10 @@ public class PreMain {
|
||||
}
|
||||
|
||||
private static boolean setLogLevel(String level) {
|
||||
if (level.equals(DEBUG)) {
|
||||
if (level.equals(MUTE)) {
|
||||
LogUtil.setDefaultLevel(LogUtil.LogLevel.LEVEL_MUTE);
|
||||
return true;
|
||||
} else if (level.equals(DEBUG)) {
|
||||
LogUtil.setDefaultLevel(LogUtil.LogLevel.LEVEL_DIAGNOSE);
|
||||
return true;
|
||||
} else if (level.equals(VERBOSE)) {
|
||||
|
Loading…
Reference in New Issue
Block a user