将断言输出记录到文件中可以通过以下步骤实现:
assertEquals(expected, actual)
来比较预期结果和实际结果是否相等。import org.apache.log4j.Logger;
private static final Logger log = Logger.getLogger(YourClassName.class);
log.info("断言输出:" + expected + " - " + actual);
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=your_log_file_path.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
领取专属 10元无门槛券
手把手带您无忧上云