1. 程式人生 > >FFA(Frighting for Ambition!)

FFA(Frighting for Ambition!)

沒使用過junit的,請看上篇部落格。
這篇講一下如何使用junit進行多執行緒併發測試 ~
實際上junit是不支援多執行緒的,你可以試試,在test方法裡面new個 Thread ~ 會報錯 ~
那你會問我在這還扯什麼犢子 ~
我當然不是在這扯犢子了
~~
有外掛 ~~ 對,有外掛!

<!-- 包依賴 -->
 <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>
${junit.verion}</version> <scope>test</scope> <optional>true</optional> </dependency> <!-- junit 多執行緒測試 --> <dependency> <groupId>fakepath</groupId> <artifactId>groboutils-core</artifactId> <version>5</version
>
<scope>test</scope> </dependency>

在junit基礎上多引入一個包,這個包可以下載不下來,彆著急,待會我上傳一個 ~ 放到本地倉庫就好了 ~ 下載連結
使用方法也是非常之簡單:

 @Test
    public void MultiRequestsTest() {
        // 構造一個Runner
        TestRunnable runner = new TestRunnable() {
            @Override
            public void runTest
() throws Throwable { //你的測試內容 } }; int runnerCount = 30; //Rnner陣列,想當於併發多少個。 TestRunnable[] trs = new TestRunnable[runnerCount]; for (int i = 0; i < runnerCount; i++) { trs[i] = runner; } // 用於執行多執行緒測試用例的Runner,將前面定義的單個Runner組成的陣列傳入 MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs); try { // 開發併發執行數組裡定義的內容 mttr.runTestRunnables(); } catch (Throwable e) { e.printStackTrace(); } }

好了,大功告成!

相關推薦

FFA(Frighting for Ambition!)(夢想註定是孤獨的旅行,路上少不了質疑和嘲笑,但那又怎樣!)

Struts2框架從零開始 從零開始到深入學習struts2框架,從最簡單的搭建框架開始,小編帶你學習struts2框架,幫你總結struts2框架使用中的技巧、細節、容易出現的問題,新手可以收藏學習。

FFA(Frighting for Ambition!)

沒使用過junit的,請看上篇部落格。 這篇講一下如何使用junit進行多執行緒併發測試 ~ 實際上junit是不支援多執行緒的,你可以試試,在test方法裡面new個 Thread ~ 會報錯

[CSS] Showing horizontal scrollbar always for the table

nbsp overflow tab spl spa horizon clas pre idt table { display: block; overflow: scroll; width: 200px; height:95vh;

Search for a Range

new sorted param for art careful span get with O(logN) This question turns to find the first and last element of the target in a sorted

Local Authentication Using Challenge Response with Yubikey for CentOS 7

fail ins path api -m ica all use debug Connect Yubikey ,then initialize YubiKey slot 2: ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac

Failed to read artifact descriptor for xxx:jar 的Maven項目jar包依賴配置的問題解決

描述 tin ava 打開 文件 我們 記事本 last .com 在開發的過程中,尤其是新手,我們經常遇到Maven下載依賴jar包的問題,也就是遇到“Failed to read artifact descriptor for xxx:jar”的

Python 7 列表 for 字典,嵌套

功能 python 結果 guest arm 表示 bsp 第一個 必須 列表:   基本格式:變量名 = [元素1,元素2,元素3]   創建:A = [‘訪客‘,‘admin‘,19] 或 A = list([‘armin‘,‘admin‘,19]), 後者更傾向

xcode工程編譯錯誤:No architectures to compile for

bis clear 文檔 哪些 i386 提高 href nts b2c 問題 開發環境:xcode6,iPhone6模擬器 xcode工程編譯錯誤:No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active

[SCSS] Write similar classes with the SCSS @for Control Directive

att oop enc rem coo tro from mil for Writing similar classes with minor variations, like utility classes, can be a pain to write and upda

for-in

們的 下標 func 可能 image arr http 是否 不能 先看一個例子: Array.prototype.searchItem = function(value){//函數已被簡化 return right; } var

JavaScript基礎 event(For IE) 顯示鼠標點擊處的坐標值 距離窗口的距離 距離網頁的距離 距離屏幕的距離

wid onclick height 屬性 ide 一個 script 點擊 ont 鎮場詩:    清心感悟智慧語,不著世間名與利。學水處下納百川,舍盡貢高我慢意。    學有小成返哺根,願鑄一良心博客。誠心於此寫經驗,願見文者得啟發。—————————————————

ios開發之 -- invalid nib registered for identifier

層級關系 註意 刪除 出現 ide 提示 sta tab 後來 今天在寫代碼的時候,碰到這麼一個問題: invalid nib registered for identifier (重用符) - nib must contain exactly one top level

No result defined for action com.action.Actionxxx and result xxx

jsp 特殊 cti nbsp 方法 def no result 使用 for 報錯:No result defined for action com.action.Actionxxx and result xxx 剛學Struts2不久,寫的第一個Action就遇到這個問

spriing boot 啟動報錯:Cannot determine embedded database driver class for database type NONE

.class sre 5.0 sin via cor pan cep can 最近在學習使用spring boot。使用maven創建好工程,只引用需要用到的spring boot相關的jar包,除此之外沒有任何的配置。 寫了一個最簡單的例子,如下所示: 1 pa

for在Linux命令行的寫法

forfor i in ...;do> action> done例如:[[email protected]/* */ tmp]# for i in $(ps -ef | grep 1.sh | awk ‘{print $2}‘);do> kill $i> done也可以直接

Render a controller in Twig - Unexpected “render” tag - expecting closing tag for the “block” tag defined

lin ack defined for ont per -i undle control Render a controller in Twig - Unexpected “render” tag - expecting closing tag for the “block

Get Docker for CentOS and Installing Docker

man inux can all pac nload require sys ont 1、OS requirements To install Docker, you need the 64-bit version of CentOS 7. 2、Uninstall old

MYSQL: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

tar new ica host star init upd pass skip 1) /etc/init.d/mysqld stop2) mysqld_safe --skip-grant-tables &3) mysql -u root4) Setup new M

(轉)SQL中的循環、for循環、遊標

from clas copy itl let alt 執行 循環 int 我們使用SQL語句處理數據時,可能會碰到一些需要循環遍歷某個表並對其進行相應的操作(添加、修改、刪除),這時我們就需要用到咱們在編程中常常用的for或foreach,但是在SQL中寫循環往往顯得那麽吃

for 循環

put tin user .get 臨時 ... 結束 -- for 1. for i in range(10): #i是臨時變量,range(10)表示從0-9 print(‘loop‘, i) 運行結果: loop 0loop 1loop 2loop 3lo