9

I have some code in my project I personally call tests that are not unit tests. They are meant to be run and the result has to be evaluated by a human. I did this because I'm making a physics engine and during development, I needed to see what I'm doing. So I made a simulation package in my test module. It is technically unit tests because the simulations are using the unit test library but I do not mean to run them all like my actual unit tests.

What I would like to do is differentiate those special tests from my unit tests because I want to run all unit tests easily. I think it is a bit like functional tests. Did you ever encounter a case where you had to prepare your application for a functional tests ? Where does that functional test preparation (basically what my simulations are) should be placed in the project and how to distinguish them from unit tests ?

I'm in Java so I could change all my methods signatures from @Test public void myNamedTest() to public static void main(String[] args) but it would be laborious and less practical for me to use my simulations.

I'm using junit in a gradle project. Any solution creating a special test folder with gradle is welcome.

FrustratedWithFormsDesigner
  • 46,105
  • 7
  • 126
  • 176
Winter
  • 705
  • 8
  • 24
  • 2
    I think what you're talking about is a *test rig* where you can run ad hoc tests. These have been around for as long as I can remember (30+ years) - possibly even before then. They usually sit in a separate project that can access the library or whatever but you can structure it however you like. – Robbie Dee Apr 26 '17 at 13:36
  • 3
    The terms unit/integration/functional tests describe the *scope* of the test: what is being tested. That's completely independent from how these tests are run, e.g. manual tests vs. automated tests. There can be automated acceptance tests and manual unit tests, and anything in between. So if you use JUnit to run manual functional tests, that's perfectly fine – just keep them somehow separate from your automatic tests so that they're not run by default. – amon Apr 26 '17 at 14:41

1 Answers1

10

It looks like later versions of Junit support categories of tests. These can be useful to classify each test. Then when the build automation runs, it can include or exclude those tests based on category.

Whether you want to mix in these tests to the unit tests is a matter of organization preference. One may want to create a separate "test rig" project to separate the regular unit tests versus the more specialized ones.

https://dzone.com/articles/closer-look-junit-categories

Jon Raynor
  • 10,905
  • 29
  • 47