-
-
Notifications
You must be signed in to change notification settings - Fork 45
add articles about testing #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I'm being picky :) - I just like consistency. In general XQuery, eXist-db, XQSuite, XML, CI, Mocha, Travis, Java, JavaScript, etc., should always be spelled the same, IMHO. Other than that the instructions are clear and really helpful!
<link xlink:href="xqsuite">XQsuite</link> | ||
</term> | ||
<listitem> | ||
<para>This is an annotation based framework that allows you to add unit tests to XQuery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotation-based
<sect1 xml:id="int-test"> | ||
<title>Introduction</title> | ||
<para>Creating an automated mininal testsuite is possible with relatively little effort. It pays to take the need for testing into account when you start developing your | ||
application. This enables others to extend your program with new features, by knowning that these don't break existing functions. It also allows test only contributions, to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean "test-only contributions", or "to test only contributions"? If it's the first one - in that case adding a "-" between 'test' and 'contributions' will clarify a bit, if it's the second, add 'to' before 'test'.
<title>Introduction</title> | ||
<para>Creating an automated mininal testsuite is possible with relatively little effort. It pays to take the need for testing into account when you start developing your | ||
application. This enables others to extend your program with new features, by knowning that these don't break existing functions. It also allows test only contributions, to | ||
help you to gradually advance your test coverage. The following section will walk you trough the three main aspects of such a minimal test setup.</para> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing 'to help' with 'helping' would make things clearer.
<para>Before you start designing tests, you should start to automate your build process. This ensures that things don't only work on your system, and it can catch some common | ||
errors.</para> | ||
<para>The examples in this article will use <link condition="_blank" xlink:href="https://travis-ci.com">travis-ci</link> as it is the most popular continual integration (ci) | ||
provider in the exist-db organization on Github, other popuar choices include <link condition="_blank" xlink:href="https://www.appveyor.com">appveyor</link>, <link condition="_blank" xlink:href="https://jenkins.io">jenkins</link>, <link condition="_blank" xlink:href="https://circleci.com">circl-ci</link>, … .</para> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eXist-db
<para>The services typically require a small configuration file, so you can build your code on a clean virtual machine, without the risk of local files interfering. For | ||
travis the required name of such a file is <literal>.travis.yml</literal> and in its simplest form it would look like this:</para> | ||
<programlisting language="yaml" xlink:href="listings/travis-1.txt"/> | ||
<para>For the correct way to create such a configuration file for other CI providers please consult their documentation. In all cases, since exist-db is written in Java, your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes 'ci' is upper-case, sometimes lower-case.
<title>Picking a Type</title> | ||
<para>Generally speaking, you should follow the sequence provided above. Whatever can be tested as part of your validation tests, is best tested there. When validation testing | ||
isn't a good fit, go for unit tests, followed by integration and lastly performance tests. The reasons for this are twofold: On the one hand, validation tests tend to be | ||
faster than unit tests, which in turn are slower then integration tests and performance tests. On the other hand, each type tends to be more easy to configure, with a higher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more easy -> easier
chance of providing you with the information that you need when a test fails.</para> | ||
<sect2 xml:id="ex-select"> | ||
<title>Selection Example</title> | ||
<para>To illustrate this, lets take a theoretical example: imagine your code includes an online form where users submit a date that needs to be stored in the database. For |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's
<title>Using native types</title> | ||
<programlisting language="xquery" xlink:href="listings/valid.txt"/> | ||
</example> | ||
<para>To check that your <literal>local:check-input</literal> function is working as expected, you can define a few <emphasis>unit test</emphasis> Typically, such a test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit test. <- add full stop
<para>To check that your <literal>local:check-input</literal> function is working as expected, you can define a few <emphasis>unit test</emphasis> Typically, such a test | ||
would include some corner cases like BCE dates, leap years, or dates in foreign date formats, as well as a basic test date that should simply store in the db.</para> | ||
<example> | ||
<title>testing corner cases</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upper-case in the title
<sect1 xml:id="coverage"> | ||
<title>Test Coverage</title> | ||
<para>Ideally, we would always achieve full test coverage for our code. So that every meaningful unit of code has a corresponding set of tests. While other programming | ||
languages offer automated means of analysing your code to indentify areas that aren't tested, such tools are unfortunately not very common for Xquery. How much testing is necessary for you to ship with confidence, rests on each developer. For apps published under the exist-db namespace, we have outlined a set of minimum requirementes (more is obviously desirable) which are featured in the section on <link condition="_blank" xlink:href="integration-testing">integration testing</link>.</para> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eXist-db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
this is a first draft for a more general article about testing strategies, and a more detailed article about integration testing. All feedback and corrections are welcome.
I'm fully expecting the need for further refinement, hence WIP