Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unit testing package naming convention

Is there even a standard convention for this? I see a lot of different and perhaps misguided package naming that is very mixed in some projects and thus is never consistent:

Let's say I want to write unit tests for something that falls under the 'stuff' package.

 com.company.product.amodule.submodule.stuff

The unit test could be one of these possibilities (or even somewhere between):

  • com.company.test.product.amodule.submodule.stuff
  • com.company.product.amodule.submodule.stuff.test
like image 440
Zombies Avatar asked Sep 10 '10 14:09

Zombies


People also ask

Should unit test naming convention?

The name of your test should consist of three parts: The name of the method being tested. The scenario under which it's being tested. The expected behavior when the scenario is invoked.

How do you name a unit test project?

A unit test method name is the first thing, anyone, trying to understand your code will read. It is important to write descriptive method names that help readers quickly identify the purpose of a test case. These method names communicate what the code does. A name should be concise, unambiguous, and consistent.

What are the naming conventions of packages?

Naming ConventionsPackage names are written in all lower case to avoid conflict with the names of classes or interfaces. Companies use their reversed Internet domain name to begin their package names—for example, com. example. mypackage for a package named mypackage created by a programmer at example.com .


1 Answers

Have it inside the same namespace (package). I like maven convention to separate source folders

src root-folders:

  • production code: src/main/...
  • test code: src/test/...

You can map this to your own build-system

like image 174
manuel aldana Avatar answered Sep 19 '22 15:09

manuel aldana