MyBatis-Plus_断言
生活随笔
收集整理的這篇文章主要介紹了
MyBatis-Plus_断言
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
MyBatis-Plus 之斷言
文章目錄
- 1. 斷言代碼:
- 2. 源碼:
- 3. 釋義:
- 4. 舉個栗子:
- 5. 異常信息:
- 6. 控制臺輸出定位
- 7. 查看數據庫:
1. 斷言代碼:
Assert.assertEquals(5, userList.size());2. 源碼:
static public void assertEquals(long expected, long actual) {assertEquals(null, expected, actual);}3. 釋義:
前面的第一個參數5表示你設置的一個值或者數 后面代碼實際的數據數 如果一樣就通過,如果不通過,就會定位在這一行代碼。
4. 舉個栗子:
1.數據庫的數據信息6條2. 斷言你寫的5條,但實際有6條3. 控制臺就會定位在這一行5. 異常信息:
at org.junit.Assert.failNotEquals(Assert.java:834)at org.junit.Assert.assertEquals(Assert.java:645)at org.junit.Assert.assertEquals(Assert.java:631)at com.gblfy.mp.mybatisplus.samplesquickstart.mapper.UserMapperTest.selectList(UserMapperTest.java:27)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)6. 控制臺輸出定位
7. 查看數據庫:
6條數據
從上面可以看出,數據庫數據信息數量和設置的數量不一致,觸發斷言。
想學習更多微服務、分布式、中間件、數據庫、項目快速構建等系列技術
請訪問http://gblfy.com
讓我們一起進步!!!
總結
以上是生活随笔為你收集整理的MyBatis-Plus_断言的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java.lang.ClassNotFo
- 下一篇: No compiler is provi