这堂课在哪里?我的项目使用JUnit 4.12,而没有找到StandardOutputStreamLog.是否会在此版本中删除?或者它来自另一个lib?这两个之间的关系是什么?
Kur*_*lar 12
SystemOutRuleStandardOutputStreamLog按照@Rahul Tripathi的建议取代.
只需添加几个指针即可立即开始使用.
Maven依赖:
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.18.0</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
将jar添加到构建路径以获取以下导入.
import org.junit.contrib.java.lang.system.SystemOutRule;
public void MyTest {
@Rule
public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();
@Test
public void writesTextToSystemOut() {
System.out.print("hello world");
assertEquals("hello world", systemOutRule.getLog());
}
}
Run Code Online (Sandbox Code Playgroud)
参考:http://stefanbirkner.github.io/system-rules/
此类已弃用,您应该使用SystemOutRule。
检查来源
StandardOutputStreamLog()
不推荐使用。
请使用新的SystemOutRule()。enableLog()。
创建一个规则,记录仍在写入标准输出流中的写入。
小智 6
不推荐使用StandardOutputStreamLog().它是JUnit 4.x包中不存在的类.我谷歌这个类加上单词maven就像这样:org.junit.contrib.java.lang.system.StandardOutputStreamLog()+ maven我发现它没有在junit Maven Repository中定义,而是在com.github.stefanbirkner中定义.所以通过添加maven坐标
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.16.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
您应该能够解决问题.
| 归档时间: |
|
| 查看次数: |
11157 次 |
| 最近记录: |