TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Tragedy of Given-When-Then

119 点作者 wheresvic1大约 6 年前

22 条评论

pjc50大约 6 年前
Whereas:<p>&gt; The reduction of the tester to an expert translator&#x2F;typist is a tragedy<p>&gt; The Given-When-Then detracts from understanding and readability but provides the much prized automation through tools like Cucumber<p>&gt; Instead of abstract domain models in Rational Rose<p>Now I see how we got into this situation. All this misery comes from the people who understand the code and the people who understand the business being different, non-intersecting groups of people.<p>Since the BAs can&#x27;t read the code, there is a desire to construct a technical representation that they <i>can</i> read, representing a some kind of formal specification, and then derive as much as possible the program from that. This was the promise of Rational Rose and the whole UML project. Had it been successful, it would have reduced programmers to stenographers, &quot;coders&quot; in a very limited sense. As it is, in a &quot;Rational&quot; system of this kind, coders end up producing increasingly elaborate polyfills between the machine-generated parts of the system and the rest.<p>The target of this is always the &quot;5GL&quot; dream:<p><pre><code> - specify program in English - ??? - automated tools transform to code </code></pre> .. without programmers involved. Unfortunately we&#x27;ve not managed to reduce the irreducible complexity of the step in the middle.<p>GWT does this de-skilling to <i>testers</i> instead; it&#x27;s effectively TDD with tests in this quasi-human-readable format that gets unimaginatively translated into programs by the testers.<p>The proposed solution is to do more communication through spreadsheet-prototypes. Since these are effectively programs in Excel, with all the real programming capabilities thereof, you get a real working model of the system that actually behaves like a program.<p>Many businesses simplify this process by then just deploying the spreadsheet to production.<p>(I&#x27;m not familiar with Cucumber, but it looks like a thing for constructing toy &quot;human readable&quot; DSLs for tests? I wonder if we could get BAs to learn INFORM?)
评论 #19675344 未加载
评论 #19678094 未加载
评论 #19674699 未加载
评论 #19676996 未加载
joshwa大约 6 年前
The article seems to assume that it is, in fact, possible to completely and correctly specify a system, and not only that, do so ahead of development.<p>This is a pipe dream in all but a minuscule slice of software projects.<p>GWT&#x2F;cucumber is as decent a tool as any for creating automated tests of system actions (and especially interactions) in a mostly-human-readable format that is likely to be understood by BAs, testers, and devs, even if not all of them are expected to be able to write them.<p>I&#x27;ve used them across many projects with great success, with the understanding that it&#x27;s not intended to replace unit tests for calculations, nor stories for initial specification.<p>As endian says downthread[0]: &quot;, G&#x2F;W&#x2F;T isn&#x27;t the solution to domain understanding, conversations are. You should be continually communicating to between all stake holders to maintain a current domain understanding.&quot;<p>[0] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19674013" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19674013</a>
评论 #19678144 未加载
评论 #19697451 未加载
pytester大约 6 年前
&gt;Although Given-When-Then is a fantastic way to describe interactions, state and behaviour, it is a lousy way to describe data and calculations.<p>I follow a slightly different technique that I think makes given&#x2F;when&#x2F;then also a useful tool for describing data and calculations.<p>1) Write the test as follows, using <i>deliberately simplified but still realistic data</i> (this is crucial):<p>&gt;Given &lt;a set of market data and trades in a table&gt; &gt;When &lt;arbitrary event such as calculation is performed&gt; &gt;Then &lt;leave blank&gt;<p>2) Write the code that outputs the data&#x2F;calculation.<p>3) Run the test in a &quot;rewrite&quot; mode that fills in the results of Then based upon actual output (this process is somewhat similar to golden master).<p>4) You now have a passing test and generated data which you can eyeball to see if it is in line with what you would expect. This test with recorded output can then be shown to the PO (or whomever) and committed to source control and used for regression testing.<p>This obviously isn&#x27;t possible with cucumber or other gherkiny tools and it does require your processes to be fully deterministic (a laudable goal anyway), but it works pretty well IMHO.
评论 #19675377 未加载
endiangroup大约 6 年前
Act 1 - G&#x2F;W&#x2F;T can be used to express iteratively aspects of an algorithm such that you can derive it without knowing or fully understanding it (algorithm triangulation: think GPS where each satellite is a constraint and you derive through iteration of each passing scenario the general algorithm).<p>Act 2 - is really about process rather than G&#x2F;W&#x2F;T (which is really just AAA, arrange, act &amp; assert).<p>Act 3 - again process, G&#x2F;W&#x2F;T isn&#x27;t the solution to domain understanding, conversations are. You should be continually communicating to between all stake holders to maintain a current domain understanding.<p>We wrote an article recently on the limits of BDD [1], G&#x2F;W&#x2F;T didn&#x27;t really come up, there are other more glaring issues with BDD when it comes to systems that intersect mismatched understandings of the real world between experts and users. Unrealistic wants and goals are killer. Additionally we started writing a tool to attach metadata to scenarios (G&#x2F;W&#x2F;T) so you can capture technical details about things called SpecStack [2]<p>[1] <a href="https:&#x2F;&#x2F;endian.io&#x2F;articles&#x2F;limits-of-bdd&#x2F;" rel="nofollow">https:&#x2F;&#x2F;endian.io&#x2F;articles&#x2F;limits-of-bdd&#x2F;</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;endiangroup&#x2F;specstack" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;endiangroup&#x2F;specstack</a>
评论 #19697508 未加载
ryanmarsh大约 6 年前
G&#x2F;W&#x2F;T is great at capturing the context&#x2F;action&#x2F;outcome of a test scenario in English. It isn’t great for all cases though. Furthermore Gherkin could be updated to allow more flexibility.<p>Having structured format for tests&#x2F;requirements, in English (et. al.), can be <i>incredibly</i> helpful. I would love to see some innovation around helping programmers and non-programmers reach a shared understanding of what the system should do and the cases we will use to verify it.<p>I don’t think unstructured conversation, unstructured English, or Excel tables are the solution. This is still an unsolved problem in our industry.
评论 #19697459 未加载
60sec大约 6 年前
The main problem with cucumber &#x2F; GWD is that in most implementations it serves as an opaque abstraction layer which is an incomplete&#x2F;incorrect model abstraction of the system itself.<p>Been doing a lot of API testing recently with karate dsl and writing cucumber tests that include json expressions with some syntactical sugar for validation. The tests serve as a specification for the system which is actually quite a bit more precise than even swagger since you can even go back in time and compare the deltas on request&#x2F;response between test executions to troubleshoot regressions.<p>Agree that GWT can&#x27;t help business understand the inherently complexity of a state machine, but individual tests can be used effectively to model state transitions, especially at the api level.
Rooster61大约 6 年前
I think a lot of the issue is the misconception that G&#x2F;W&#x2F;T feature files can essentially replace specifications&#x2F;requirements. They can and absolutely should REFLECT the requirements, but they are ill suited to act as the actual specifications themselves.<p>Feature files to me are most effective when they act as a roadmap of the steps one needs to take to effectively test a given set of use cases, NOT a 1-1 carbon copy of the requirements. It should tell a non-programmer what the test is doing without having to dive into the code, while being a scaffold to which a programmer can build their test logic into. If one needs to look at the requirements, one should do just that, read the requirements document, or in the developer&#x27;s case, read the requirements set forth in the user story. Scenarios are guides to how to navigate what the test is doing, not what the application itself should be doing.<p>Also, I often see programmers attempt to write a BDD test and run into a case that doesn&#x27;t quite fit flush into G&#x2F;W&#x2F;T, then ask the community of how they might go about writing that test. Instead of understanding flexibility, they are met with an abrupt &quot;that&#x27;s not BDD, you are doing it wrong, if you did it the BDD way everything would work out&quot;. That&#x27;s discouraging, frustrating, and destructive. G&#x2F;W&#x2F;T is not gospel, and it doesn&#x27;t fit all test cases. I see nothing wrong with fudging some tests to not follow Gherkin to-the-letter if it better facilitates a test while still remaining clear what the test is doing in plain English within the feature file&#x27;s scenario.
neves大约 6 年前
I can&#x27;t agree more. I&#x27;m still to see a testing tool that can be used for specification and used by end users. Today everything is developer centric. Maybe there&#x27;s no escape to this. The solution is really to make your developers understand the business.
评论 #19673882 未加载
评论 #19679346 未加载
评论 #19697518 未加载
RHSeeger大约 6 年前
&gt; We will realise that describing data and calculations using the Given-When-Then format leads to tragedy, and will create and popularise tools and approaches using Excel to document examples.<p>Given all the examples given, it sounds more like Cucumber is the problem. Having specifications&#x2F;tests written in the form of given-when-then isn&#x27;t shown to have any issues. Rather, taking those specs&#x2F;requirements and disconnecting them from the people who need them is the issue.
评论 #19673807 未加载
评论 #19675658 未加载
评论 #19674222 未加载
rgoulter大约 6 年前
<i>A common anti-pattern with Given-When-Then has the Three Amigoes collaborating on scenarios that are stored as acceptance criteria in user stories.</i><p>I agree with this. Writing Cucumber&#x2F;Gherkin scenarios is extra effort if the Cucumber files themselves aren&#x27;t used&#x2F;read elsewhere. -- It&#x27;d be simpler to embed &quot;Given&#x2F;When&#x2F;Then&quot; statements within test code (like RSpec).<p>I&#x27;d emphasise that Gojko Adzic&#x27;s &quot;Specification By Example&quot; suggests discussing examples before refining to a specification; that may get around the author&#x27;s complaint that non-table formats don&#x27;t allow for important cases.<p>That said, &quot;Given&#x2F;When&#x2F;Then&quot; is hardly magical, so doesn&#x27;t deserve much praise&#x2F;criticism itself. Any test involves &quot;do an action, check the result&quot; (with &quot;setup the system&quot; and &quot;cleanup&quot; being implied). Sometimes called &quot;Assemble, Act, Assert&quot;. &quot;G&#x2F;W&#x2F;T&quot; is just a neat, consistent format for describing behaviour in English. A table of values specifies some computation; the column titles help to describe that behaviour.
评论 #19675702 未加载
dmitryminkovsky大约 6 年前
This is why I like Spock [0]. You can go G&#x2F;W&#x2F;T&#x2F;, W&#x2F;T, T, or Expect [1]. It&#x27;s billed as &quot;multi-paradigm&quot; which really just means you can do whatever feels right for a given case. Also its data table feature is wonderful [2][3].<p>[0]: <a href="http:&#x2F;&#x2F;spockframework.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;spockframework.org&#x2F;</a><p>[1]: <a href="http:&#x2F;&#x2F;spockframework.org&#x2F;spock&#x2F;docs&#x2F;1.3&#x2F;spock_primer.html#_blocks" rel="nofollow">http:&#x2F;&#x2F;spockframework.org&#x2F;spock&#x2F;docs&#x2F;1.3&#x2F;spock_primer.html#_...</a><p>[2]: <a href="http:&#x2F;&#x2F;spockframework.org&#x2F;spock&#x2F;docs&#x2F;1.3&#x2F;data_driven_testing.html" rel="nofollow">http:&#x2F;&#x2F;spockframework.org&#x2F;spock&#x2F;docs&#x2F;1.3&#x2F;data_driven_testing...</a><p>[3]: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;dminkovsky&#x2F;status&#x2F;1116727735399976966" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;dminkovsky&#x2F;status&#x2F;1116727735399976966</a>
评论 #19677019 未加载
raldi大约 6 年前
This article would have been better if at some point it explained what Given-When-Then is.
评论 #19677626 未加载
verisimilitudes大约 6 年前
&gt;Before the internet, user experience was considered of little value because most users of systems were internal employees of companies.<p>I&#x27;m skeptical of this claim. It would help if there were a year, considering it&#x27;s not clear if the author means the modern Internet, the ARPANET, or when the modern Internet became widely available to a larger group of people. Based on the mentions of Excel, I&#x27;m inclined to believe it&#x27;s the last option I listed.<p>The MIT AI lab and other research areas come to mind as places that cared about how the programs were operated and whatnot and these weren&#x27;t exclusively used by employees. SHRDLU comes to mind. While I&#x27;m thinking about it, the Apple Macintosh also does.<p>I don&#x27;t believe I was familiar with this Given-When-Then model beforehand, but I also think that&#x27;s because it&#x27;s somewhat natural, or at least seems natural. The author has failed to convince me why this is a bad thing. I suppose I can see why these larger business practices are poor, but that has me failing to see why this particular practice is singled out.
exelius大约 6 年前
Yeah; I suspect the core of the problem is that too many software developers fancy themselves business analysts while too many business analysts start to cower in fear whenever you suggest they check something in to GitHub.
评论 #19673427 未加载
projektfu大约 6 年前
You might want to check out Fit as a testing framework that may be more appropriate for your use case than Cucumber. Not sure if it&#x27;s still well maintained, but it could be brought up to speed without much effort.
noveltyaccount大约 6 年前
To;Dr, given-when-then can sometimes obscure requirements rather than illuminate them. Use Excel or other tools to document such scenarios, as everyone in the software design process can understand Excel formulas.
评论 #19673790 未加载
jrochkind1大约 6 年前
I think there&#x27;s a lot of people down on cucumber after experience with it, in several different contexts... what do you think, what has been your experience?
评论 #19675959 未加载
评论 #19675681 未加载
philipodonnell大约 6 年前
&gt; The discussion helped me realise that Given-When-Then is as much of a hindrance in some contexts as it is a help in other contexts.<p>I like when authors express a strong viewpoint but then also include descriptions of circumstances where their viewpoint may not be applicable. This seems to be alluded in the above quote, but are there specific contexts where Given-When-Then _is_ helpful and the appropriate mechanism to document requirements?
评论 #19674900 未加载
xchip大约 6 年前
That is pretty much the core of software engineering, I&#x27;d call it Data-If-Then and I fail to see why this is a tragedy.
评论 #19673223 未加载
barbecue_sauce大约 6 年前
What ever happened to Systems Analysts?
jodrellblank大约 6 年前
arcfide has claimed on several occasions that non-programmers take to APL quite easily, and can read and collaborate on it with a programmer, be talked through it directly, in a way they can&#x27;t&#x2F;won&#x27;t do for mainstream languages.<p>I find this such an unlikely sounding claim that I want to reject it without consideration, or at least assume that he&#x27;s only talking to a very restricted subset of engineering non-programmers.<p>APL is decades old and very much a business language by origin in IBM System 360, there ought to be decades of people&#x27;s experience with this on both sides to back it up or refute it - programmer and non-programmer. Is there?
macca321大约 6 年前
It&#x27;s a fallacy that GWT has to be at the browser automation level. And it&#x27;s a lot easier to understand the point of a test if it&#x27;s got GWT comments interspersed with the code.