From a76be496bf4409654b792e4e3d409590992181bc Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 29 Mar 2021 00:26:31 +0200 Subject: [PATCH 1/2] Add some hints on test tooling --- docs/getting-into-the-code/code-howtos.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md index 45b72a2957b..b4f9ee26ca7 100644 --- a/docs/getting-into-the-code/code-howtos.md +++ b/docs/getting-into-the-code/code-howtos.md @@ -229,6 +229,24 @@ Defaults should go into the model package. See [Comments in this Commit](https:/ ## Test Cases +### Background on Java testing + +In JabRef, we mainly rely to basic JUnit tests to increase code coverage. +There are other ways to test: + +| Type | Techniques | Tool (Java) | Kind of tests | Used In JabRef | +| -- | -- | -- | -- | -- | +| Functional | Dynamics, black box, positive and negative | [JUnit-QuickCheck](https://github.com/pholser/junit-quickcheck) | Random data generation | No, not intended, because other test kinds seem more helpful. | +| Functional | Dynamics, black box, positive and negative | [GraphWalker](https://graphwalker.github.io/) | Model-based | No, because the BibDatabase doesn't need to be tests | +| Functional | Dynamics, black box, positive and negative | [TestFX](https://github.com/TestFX/TestFX) | GUI Tests | Yes | +| Functional | Dynamics, white box, negative | [PIT](https://pitest.org/) | Mutation | No | +| Functional | Dynamics, white box, positive and negative | [Mockito](https://site.mockito.org/) | Mocking | Yes | +| Non-functional | Dynamics, black box, positive and negative | [JETM](http://jetm.void.fm/), [Apache JMeter](https://jmeter.apache.org/) | Performance (performance testing vs load testing respectively) | No | +| Structural | Static, white box | [CheckStyle](https://checkstyle.sourceforge.io/) | Yes | +| Structural | Dynamics, white box | [SpotBugs](https://spotbugs.github.io/) | No | + +### General hints on tests + Imagine you want to test the method `format(String value)` in the class `BracesFormatter` which removes double braces in a given string. * _Placing:_ all tests should be placed in a class named `classTest`, e.g. `BracesFormatterTest`. From 75b92bfda63ba31bfc75cb3758196dcf93103b64 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 29 Mar 2021 20:40:01 +0200 Subject: [PATCH 2/2] Fix comments --- docs/getting-into-the-code/code-howtos.md | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md index b4f9ee26ca7..61a4af33233 100644 --- a/docs/getting-into-the-code/code-howtos.md +++ b/docs/getting-into-the-code/code-howtos.md @@ -229,22 +229,6 @@ Defaults should go into the model package. See [Comments in this Commit](https:/ ## Test Cases -### Background on Java testing - -In JabRef, we mainly rely to basic JUnit tests to increase code coverage. -There are other ways to test: - -| Type | Techniques | Tool (Java) | Kind of tests | Used In JabRef | -| -- | -- | -- | -- | -- | -| Functional | Dynamics, black box, positive and negative | [JUnit-QuickCheck](https://github.com/pholser/junit-quickcheck) | Random data generation | No, not intended, because other test kinds seem more helpful. | -| Functional | Dynamics, black box, positive and negative | [GraphWalker](https://graphwalker.github.io/) | Model-based | No, because the BibDatabase doesn't need to be tests | -| Functional | Dynamics, black box, positive and negative | [TestFX](https://github.com/TestFX/TestFX) | GUI Tests | Yes | -| Functional | Dynamics, white box, negative | [PIT](https://pitest.org/) | Mutation | No | -| Functional | Dynamics, white box, positive and negative | [Mockito](https://site.mockito.org/) | Mocking | Yes | -| Non-functional | Dynamics, black box, positive and negative | [JETM](http://jetm.void.fm/), [Apache JMeter](https://jmeter.apache.org/) | Performance (performance testing vs load testing respectively) | No | -| Structural | Static, white box | [CheckStyle](https://checkstyle.sourceforge.io/) | Yes | -| Structural | Dynamics, white box | [SpotBugs](https://spotbugs.github.io/) | No | - ### General hints on tests Imagine you want to test the method `format(String value)` in the class `BracesFormatter` which removes double braces in a given string. @@ -334,6 +318,22 @@ public void getTypeReturnsBibLatexArticleInBibLatexMode() { To test that a preferences migration works successfully, use the mockito method `verify`. See `PreferencesMigrationsTest` for an example. +### Background on Java testing + +In JabRef, we mainly rely to basic JUnit tests to increase code coverage. +There are other ways to test: + +| Type | Techniques | Tool (Java) | Kind of tests | Used In JabRef | +| -- | -- | -- | -- | -- | +| Functional | Dynamics, black box, positive and negative | [JUnit-QuickCheck](https://github.com/pholser/junit-quickcheck) | Random data generation | No, not intended, because other test kinds seem more helpful. | +| Functional | Dynamics, black box, positive and negative | [GraphWalker](https://graphwalker.github.io/) | Model-based | No, because the BibDatabase doesn't need to be tests | +| Functional | Dynamics, black box, positive and negative | [TestFX](https://github.com/TestFX/TestFX) | GUI Tests | Yes | +| Functional | Dynamics, white box, negative | [PIT](https://pitest.org/) | Mutation | No | +| Functional | Dynamics, white box, positive and negative | [Mockito](https://site.mockito.org/) | Mocking | Yes | +| Non-functional | Dynamics, black box, positive and negative | [JETM](http://jetm.void.fm/), [Apache JMeter](https://jmeter.apache.org/) | Performance (performance testing vs load testing respectively) | No | +| Structural | Static, white box | [CheckStyle](https://checkstyle.sourceforge.io/) | Constient formatting of the source code | Yes | +| Structural | Dynamics, white box | [SpotBugs](https://spotbugs.github.io/) | Reocurreing bugs (based on experience of other projects) | No | + ## UI Global variables should be avoided. Try to pass them as dependency.