0

I want to test files, for this I have a Java program with different packages.

  • "checkFileSize"
  • "checkFileLocation"
  • and so on

the tests return only true and false (the tests are main classes in the package)

the individual packages are different stages in a gitlab pipe. for example:

  • "checkFileSize"
  • "checkFileLocation"

the stages run one by one, i.e. if the first "test" fails the runner aborts. otherwise the next stage should run, etc.

is this a good concept? are there already sample programmes for this?

Thanks a lot

MWiesner
  • 8,868
  • 11
  • 36
  • 70

1 Answers1

0

My recommendation would be to rewrite your tests classes to actual tests (with e.g. junit). Then you could just run a mvn test (o gradle or whatever you use).

Also, I would not use one stage per test as this makes you process much slower, because you have the overhead of the docker setup etc. for each stage separately.

By the way, I do not really get your approach

the tests return only true and false (the tests are main classes in the package)

as Java applications don't really have a return value (the entry point is usually a public static void main). What they do have is a status code which you can set via System.exit(). A nonzero status code indicates abnormal termination. You could actually use this to indicate that your test has failed but I really would recommend to use test classes as described above.

Sebastian
  • 5,721
  • 3
  • 43
  • 69