關於junit的使用問題

2021-08-17 04:18:54 字數 759 閱讀 9389

第一次使用junit的時候出現錯誤:

error statuslogger log4j2 could not find a logging implementation. please add log4j-core to the classpath. using ******logger to log to the console...

error statuslogger no log4j2 configuration file found. using default configuration: logging only errors to the console.

在src目錄下新增log4j2.xml配置未見

<?

xml version

="1.0"

encoding

="utf-8"

?>

status

="warn"

>

name

="console"

target

="system_out"

>

pattern

="%d [%t] %-5level %logger - %msg%n"

/>

level

="error"

>

="console"

/>

問題就解決了,只是記錄了自己犯的錯誤,同時提供參考,大神勿噴~

下面是筆者參考解決方案的原文

參考原文

Junit使用中的問題

注意黑色加下劃線的部分。說明4.1.1中沒有hamcrest包了,不知道作者是怎麼想的。解決方法是 使用是匯入包的方案 junit.jar hamcrest core.jar hamcrest library.jar 或 junit dep.ajr hancrest all.jar 這兩種匯入方法雖...

關於JUnit測試的最簡單使用

只是寫乙個小入門,簡單輸出文字,沒啥?首先,建立乙個messageutil類,用來測試 package com.test.jiao public class messageutil public string printmessage 然後,建立testcase 類,命名為testjunit,測試時...

Junit 使用問題記錄

1.必須是public,無參,非靜態,如下 test public void func 2.eclipse執行乙個test方法 在package explorer中選擇測試類,展開,從中選擇要測試方法,右鍵run as juint test 3.只新增junit.jar不夠,還需新增hamcrest...