ATDD,Gherkin,Specflow方法,黑盒测试问题

时间:2017-04-03 10:34:48

标签: testing bdd specflow gherkin atdd

我正试图在ATDD的外部发展方面获得一些经验,现在我遇到了第一个障碍。

该应用程序是一个简单的桌面应用程序(wpf),它应该能够在文件系统中搜索重复项。

我想要实现的第一个功能是自定义应搜索的目录。但我不知道我应该如何端到端地测试该功能。

使用2个文件(重复项)创建测试目录是一个很好的自动化方法,然后通过用户界面选择该目录然后开始搜索并验证结果是2个创建的文件?

我会测试更多,然后只是用于指定搜索目录的功能。

功能:CustomizeSearchDirectories

;; generic function to walk trees and reduce
;; by combiner every value accessed by term 
;; the default argument to combiner is tree-null
(defun accumulate-tree (tree term combiner null-value)
  (labels ((rec (tree)
             (cond ((null tree) null-value)
                   ((atom tree) (funcall term tree))
                   (t (funcall combiner (rec (car tree)) 
                                        (rec (cdr tree)))))))
    (rec tree)))

(defun sum-numbers (tree)
  (accumulate-tree tree
                   #'identity
                   #'+
                   0))

(defun count-numbers (tree)
  (accumulate-tree tree
                   (lambda (v) (if (numberp v) 1 0)) 
                   #'+
                   0))

(sum-numbers '((1) (2 3) (((4)) 5)))   ; ==> 15
(count-numbers '(a b 4 3 (e f 5) . 9)) ; ==> 4

感谢可以减少我的困惑的反馈

1 个答案:

答案 0 :(得分:0)

如果您愿意,在BDD或ATDD中,您无需端到端地测试所有内容。以某种方式使用系统然后监视它并看到预期的事情已经发生是完全正常的。

在您的情况下,“自定义应搜索的目录”,我会考虑指定目录并确保我可以验证它们是否已正确指定。这并不一定意味着使用用户界面。

Scenario: customize the directories which should be searched
  Given Thomas wants to search two directories
  When he selects ./tmp and ./home/thomas
  Then should ./tmp and ./home/thomas be selected

此示例指定了我想要的内容,要搜索的目录以及最终验证它们将被搜索的目录。它没有指定是否涉及文件系统,它没有指定任何UI细节。那些东西可以而且应该被推到堆栈中,以便稍后使用这些步骤。

这意味着您可以验证核心逻辑,选择两个目录,或者您可以从用户界面验证与系统的交互。

我要做的第一件事就是验证核心逻辑。如果我需要,我可以稍后在用户界面验证它。