我正在编写一些使用python unittest包的测试(Python 2.7) 我非常依赖xmlrunner.XMLTestRunner来转储XML测试输出
不幸的是,我找不到一些基本的例子,它描述了如何将一些命令行选项传递给测试类来参数化一些测试。 是否有人提示我如何实现这一目标(使用xmlrunner)?
此外,这是我尝试实现的目标: 我在以下 myunittest.py 文件中的一组类中定义了我的测试:
grunt.task({
// Do Stuff here
})
并从 main.py 调用它,如下所示:
import unittest
class TestOne(unittest.TestCase):
def __init__(self, options=None):
unittest.TestCase.__init__(self)
self.__options = options
def A(self):
print self.__options.configXML # try to print the parameter
self.assertEqual(1, 1)
非常感谢您的宝贵帮助。
答案 0 :(得分:1)
<!DOCTYPE html>
<head><title>Adventure Game</title>
<link src="/home/logan/game2" type="text/javascript">
</head>
<body>
<script type="text/javascript"></script>
<script>
confirm("Ready to play?");
var age = prompt("How old are you?");
if (age >= 18) {
document.write(" ");
} else {
document.write("You're less than 18? You better just stay home, filthy pansy.");
}
document.write("Please select your gender.")
</script>
<p>
<select id="genderlist">
<option value="null"> </option>
<option value='Male'> Male </option>
<option value='Female'> Female </option>
<option value='Other'> Other </option>
</select>
</p>
<script>
document.getElementById("genderlist").onchange = function() {
var gender=document.getElementById("genderlist").value;
if(gender=="Male"){
document.write("Okay");
document.write('<p><button id="start" onclick="function()"> Lets begin, shall we?</button></p>');
}
else if(gender=="Female"){
document.write("Sounds Good");
document.write('<p><button id="start"> Lets begin, shall we?</button></p>');
}
else{
document.write("I don't think this will be for you.");
}
return false
};
</script>
<script>
document.getElementById("start").onclick = function(){
document.write("<p> This is nice </p>");
};
</script>
</body>
</html>
使用test.py:
python test.py --xmlConfig=configFile.xml --xmlRunner