And I end up going back and doing unit testing anyway, to try and figure out why it doesn't work. So over the years, I've just convinced myself I might as well start where I'm going to end up.
第一次从来不会正常运行,因此无论如何我还要回头去做单元测试,找找哪儿出错了,因此经过这么多年,我已经说服自己既然一定要做单元测试,那么还是一开始就做最好了。
Well, you could just try it and see if it works, right? That's what testing is all about.
你可以仅仅的去试试运行程序,然后看看结果对不对?这就是测试的内容。
I should really just put it in a nice test harness, where I run 100, 200, 1,000 trials, but I didn't want to bore you with that here.
我应该把它放到一个测试组件中,我运行100次,200次,1000次,但是我现在不想用这个来烦你们。
Testing and reasoning. Testing, we run our program on some set of inputs.
测试就是,我们输入一些信息,并且运行我们的程序,然后查看答案。
So let's assume we've run our test suite.
让我们假设已经运行了测试集。
For the latter, this is a place where running test cases would do a good job of helping with that. Nonetheless, having done that, let's look at a better way to write this. Which is right here it is also, I think, on your sheet, I'm going to uncomment that, and comment this one out, yeah. All right?
对于后者来说,运行测试用例,对它会有很大的帮助,尽管如此,讲完了这些,让我们再来看看更好的,来写这个程序的一种方法吧,也就是这里,我想这程序也在,你们的课堂手册上面,我得先把这里取消注释,然后注释掉这里,是的,对不对?
I spotted an error here, I could have spotted it by running it on different test sets, and using prints things, another way of doing it, but this idea of at least simulating it on simple examples lets you check a couple of important questions.
操作么?我在这里发现了一个错误,我也可以通过运行不同的测试集,或者运用print声明来发现这个错误,但是至少应该用简单的例子来手工模拟下,代码的思想可以让你,对一些很重要的问题进行检验。
应用推荐