0

The convention for java and scala in main package is:

  main/
    java-or-scala/
      inverted.domain.convetion/
        foo/

What about the test package? Is there a convention? Should it be:

  test/
   java-or-scala/
      inverted.domain.convetion
        fooTest/

or can it be:

  test/
   java-or-scala/
        fooTest/

?

YFl
  • 845
  • 7
  • 22
  • 6
    it should be the same. espacially if you want to measure the code coverage it must be the same – Jens Jun 02 '22 at 16:26
  • thanks, @Jens. Is it because converge tools expect it to be this way? Do maven and sbt also expect it to be the same in the test package? Thanks, again. – YFl Jun 02 '22 at 16:29
  • 1
    It is the coverage tool. maven doesn't need the same structure – Jens Jun 02 '22 at 16:30
  • 6
    It is a good idea to test classes to be in the same package as the classes they are testing. – Luis Miguel Mejía Suárez Jun 02 '22 at 16:36
  • 1
    Also if you want to test a private method in package `com.foo.bar`, you can use `private[bar]` to make it accessible in `com.foo.bar` package in your unit tests. – Ava Jun 02 '22 at 21:42
  • Hey, @Ava, that's interesting. Can you please point me to some resource about it, so I can learn more? Thank you. – YFl Jun 03 '22 at 09:55
  • 1
    For scopes in Scala: https://alvinalexander.com/scala/how-to-control-scala-method-scope-object-private-package/. Regarding the use case that I've mentioned the easiest way is to test it yourself or refer to this answer: https://stackoverflow.com/a/21369609/9134945. – Ava Jun 04 '22 at 10:14
  • Good resource. Thanks – YFl Jun 15 '22 at 21:29

0 Answers0