मैं इस समझौते में हूं कि जसुनिट बेल पर मरने की तरह है। हमने इसे यूयूआई टेस्ट के साथ बदल दिया।
QUnit का उपयोग कर उदाहरण के समान, हम सेलेनियम का उपयोग करके परीक्षण चला रहे हैं। हम इस परीक्षण को हमारे अन्य सेलेनियम परीक्षणों से स्वतंत्र रूप से चला रहे हैं क्योंकि इसमें सामान्य यूआई रिग्रेशन परीक्षणों (जैसे सर्वर पर ऐप को तैनात करना) निर्भरता नहीं है।
शुरू करने के लिए, हमारे पास मूल जावास्क्रिप्ट फ़ाइल है जो हमारी सभी परीक्षण HTML फ़ाइलों में शामिल है। यह वाईयूआई इंस्टेंस, टेस्ट रनर, वाईयूआई.स्टेस्ट ऑब्जेक्ट के साथ-साथ टेस्ट। केस स्थापित करने में संभालता है। इसमें एक विधि है जिसे टेस्ट सूट चलाने के लिए सेलेनियम के माध्यम से एक्सेस किया जा सकता है, यह जांचने के लिए जांचें कि क्या परीक्षण धावक अभी भी चल रहा है (परिणाम तब तक उपलब्ध नहीं हैं जब तक यह पूरा नहीं हो जाता है), और परीक्षा परिणाम प्राप्त करें (हमने JSON प्रारूप चुना है)
var yui_instance; //the YUI instance
var runner; //The YAHOO.Test.Runner
var Assert; //an instance of YAHOO.Test.Assert to save coding
var testSuite; //The YAHOO.Test.Suite that will get run.
/**
* Sets the required value for the name property on the given template, creates
* and returns a new YUI Test.Case object.
*
* @param template the template object containing all of the tests
*/
function setupTestCase(template) {
template.name = "jsTestCase";
var test_case = new yui_instance.Test.Case(template);
return test_case;
}
/**
* Sets up the test suite with a single test case using the given
* template.
*
* @param template the template object containing all of the tests
*/
function setupTestSuite(template) {
var test_case = setupTestCase(template);
testSuite = new yui_instance.Test.Suite("Bond JS Test Suite");
testSuite.add(test_case);
}
/**
* Runs the YAHOO.Test.Suite
*/
function runTestSuite() {
runner = yui_instance.Test.Runner;
Assert = yui_instance.Assert;
runner.clear();
runner.add(testSuite);
runner.run();
}
/**
* Used to see if the YAHOO.Test.Runner is still running. The
* test results are not available until it is done running.
*/
function isRunning() {
return runner.isRunning();
}
/**
* Gets the results from the YAHOO.Test.Runner
*/
function getTestResults() {
return runner.getResults(yui_instance.Test.Format.JSON);
}
चीजों के सेलेनियम पक्ष के लिए, हमने एक पैरामीटर परीक्षण का उपयोग किया। हम डेटा परीक्षण में आईई और फ़ायरफ़ॉक्स दोनों में हमारे परीक्षण चलाते हैं, परीक्षण परिणामों को ब्राउज़र सरणी, परीक्षण फ़ाइल नाम, परीक्षण नाम, परिणाम (पास, विफल या अनदेखा) वाले प्रत्येक सरणी के साथ ऑब्जेक्ट एरे की एक सूची में पार्स करते हैं। और संदेश।
वास्तविक परीक्षण सिर्फ परीक्षा परिणाम का दावा करता है। यदि यह "पास" के बराबर नहीं है तो यह वाईयूआई परीक्षा परिणाम से लौटाए गए संदेश के साथ परीक्षण में विफल रहता है।
@Parameters
public static List
मुझे आशा है कि यह मददगार है।