TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Spek – A Specification Framework

42 pointsby hhaririover 11 years ago

12 comments

colandermanover 11 years ago
&gt; <i>Tests are specifications</i><p>No, they&#x27;re not. Unless you&#x27;re OK with the system working for only exactly the test cases you specify (which, btw, is trivially implementable as a look-up table of the test cases!), tests <i>do not</i> specify a system.<p>EDIT: Importantly, tests have no means of distinguishing for a missing test case whether that case&#x27;s behavior should be <i>inferred</i> or is <i>actually unspecified</i>.<p>See <a href="http://en.wikipedia.org/wiki/Z_notation" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Z_notation</a> for an example of an actual serious specification language.
评论 #7252626 未加载
评论 #7252417 未加载
评论 #7252295 未加载
frederikbover 11 years ago
An interesting alternative to this is Spock [1], a specification framework for Java and Groovy with a nice Groovy DSL. Check out the new reference documentation [2] or try out some specifications using the web console [3].<p>It has a great syntax for data driven and interaction based syntax.<p>Data driven example:<p><pre><code> class Math extends Specification { def &quot;maximum of two numbers&quot;(int a, int b, int c) { expect: Math.max(a, b) == c where: a | b | c 1 | 3 | 3 7 | 4 | 4 0 | 0 | 0 } } </code></pre> [1] <a href="https://code.google.com/p/spock/" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;spock&#x2F;</a><p>[2] <a href="http://docs.spockframework.org/en/latest/" rel="nofollow">http:&#x2F;&#x2F;docs.spockframework.org&#x2F;en&#x2F;latest&#x2F;</a><p>[3] <a href="http://meetspock.appspot.com/" rel="nofollow">http:&#x2F;&#x2F;meetspock.appspot.com&#x2F;</a>
评论 #7257028 未加载
noelwelshover 11 years ago
There is this odd trend amongst testing framework developers to make their frameworks more verbose, as if this somehow delivers value. Spek seems to be in this tradition. Almost every other area of programming aims towards getting as much work done with as a little verbiage as possible. Why do testing framework people feel that programs should read like written prose? This idea has failed a great many times over the years.<p>The ScalaCheck [0] library is actually innovating in the domain of testing. It&#x27;s derived from QuickCheck, a Haskell library, and I believe an Erlang derivative is making $$s as a commercial product.<p>[0]: <a href="https://github.com/rickynils/scalacheck" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rickynils&#x2F;scalacheck</a>
评论 #7253153 未加载
评论 #7253117 未加载
评论 #7252651 未加载
评论 #7252817 未加载
评论 #7252717 未加载
biotover 11 years ago
Name and functionality inspired by Spec# [0] ... just a bit? Sample Spec# code:<p><pre><code> int ISqrt(int x) requires 0 &lt;= x; ensures result*result &lt;= x &amp;&amp; x &lt; (result+1)*(result+1); { int r = 0; while ((r+1)*(r+1) &lt;= x) invariant r*r &lt;= x; { r++; } return r; } </code></pre> [0] <a href="http://research.microsoft.com/en-us/projects/specsharp/" rel="nofollow">http:&#x2F;&#x2F;research.microsoft.com&#x2F;en-us&#x2F;projects&#x2F;specsharp&#x2F;</a>
评论 #7252292 未加载
hugofirthover 11 years ago
Building tooling like this seems a no-brainer as far as language uptake is concerned.<p>Testing libraries offer a low friction, low risk way to introduce new JVM based languages to an existing project.<p>Scalatest was certainly Scala&#x27;s &quot;foot in the door&quot; for the last project where we managed to sell the switch from Java to Scala.<p>On a related note: I would really like to see an in depth comparison between Scala and Kotlin. The two seem idealogically and syntactically similar.
royjacobsover 11 years ago
This seems to be influenced by MSpec [0] which is a really elegant framework. I&#x27;m not sure if I like having to use Kotlin, though.<p>[0] <a href="https://github.com/machine/machine.specifications" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;machine&#x2F;machine.specifications</a>
badman_tingover 11 years ago
I am not sure if something like Jasmine or Chai exists in the JVM world but this seems pretty similar. You can do much the same thing with BDD-style describe() and it() specs.
WimLeersover 11 years ago
FYI: &quot;spek&quot; is Dutch for &quot;bacon&quot; — <a href="http://nl.wikipedia.org/wiki/Spek" rel="nofollow">http:&#x2F;&#x2F;nl.wikipedia.org&#x2F;wiki&#x2F;Spek</a>.
评论 #7252754 未加载
louisdefunesover 11 years ago
Funny but Python code is more readable than their DSL !
jackgaviganover 11 years ago
There&#x27;s already a perfectly good language for creating specifications: English.
评论 #7252801 未加载
sz4kertoover 11 years ago
Seems to be very similar to Scalatest. What&#x27;s not a bad sign.
yawzover 11 years ago
It funnily looks like scalatest (FunSpec, ShouldMatchers, etc.).