簡體   English   中英

[插入語言]的測試框架

[英]Test framework for [insert language here]

我正在尋找一個測試框架,為沒有太多測試支持的語言引入自動化測試。 據我所知,我需要一個能夠使用某種形式的協議運行VDF測試的框架。 我寧願花時間編寫測試而不是編寫VDF代碼來與測試框架接口,因此更喜歡輕量級協議。

與Fitnesse苗條似乎是一個不錯的候選人,但我對所有建議感興趣。

能夠在編程語言中使用相同的測試框架將是一個額外的好處。

這假設您正在API級別工作。 如果我讀錯了,並且你在GUI級工作,你更容易考慮像selenium或watir這樣的東西。

您是否考慮過編寫自己的簡單測試框架來輸出TAP結果(測試任何協議) - 然后用grind或TAP2HTML解析它?

說真的,TAP輸出如下:

1..7
ok 1 - hello world with null value returns 'hello world' string
ok 2 - hello world with bob returns 'hello, bob'
ok 3 - hello world with 123 return 'hello, 123'
ok 4 - hello world with 5K string return hello plus string
ok 5 - special characters
ok 6 - internationalization, fr
ok 7 - internationalization, ja
Looks like you failed 0 tests of 7.

(如果它在第5步之后死亡,1..7就會告訴你一些錯誤)

輸出是直接ASCII。 你基本上有兩個全局變量,numTestsTotal和numTestExecuted,並寫這樣的函數:

sub ok (boolean bExpected, string comment) {
  if (bExpected) {
    print "ok " . numTestsExecuted . " "  . comment . "\n";    
  }else {
    print "not ok" . numTeststotal . " " . comment . "\n";
  }
  numTestsExecuted++;
}


sub eq(int iExpected, int iResult, string comment) {
  if (iExpected==iResult) {
     print "ok " . numTestsExecuted . " " . comment . "\n";
  } else {
     print "not ok" . numTestsExecuted . " " . comment . \n";
  }
  numTestsExecuted++;
}

您在庫中編寫常規代碼,然后您的測試應用程序包括庫和測試模塊。

您可以為每種類型的值重載eq,而write是比較數組等。

請參閱TAP上的文檔: http//testanything.org/wiki/index.php/Main_Page

測試::更多

是的,你可以說eq()應該“只”調用ok()。 或者您可以在輸出中插入預期和實際結果。 由你決定。

無論如何,有許多TAP解析器和解釋器用於更多命令式語言。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM