If I have two packages com.application.
* and com.test.
and I don't want to run com.test.*.
package in production, but need to run com.test.*
package in uat. How can I do this?
Asked
Active
Viewed 104 times
0

user229044
- 232,980
- 40
- 330
- 338

Abhendra Singh
- 1,959
- 4
- 26
- 46
-
Can you make this a little more clear? I think an import statement is what you're looking for, but I honestly have no idea what you're asking for. – Michael Barz Jul 10 '14 at 16:17
-
1Well, you can have any *test* package under a different source folder, like maven states for your projects, and specify the maven commands to compile and execute the code for UAT and Prod environments, UAT containing test packages and Prod ignoring them at all. – Luiggi Mendoza Jul 10 '14 at 16:25
-
Security manager might get you there: http://stackoverflow.com/questions/11606787/security-restrict-internal-access-by-third-party-software – spudone Jul 10 '14 at 17:15
1 Answers
0
The simple, straightforward answer is this: don't build your test packages in the same source directory as your production code. Package structure at this level doesn't apply. (And the tests really should be in the same package structure as the source it's testing; keeps tests and code organized hierarchially.)
Maven already employs this strategy by separating out your production source code from your test source code by giving you two folders by default: src/main
and src/test/
. Gradle also respects this and won't build your test code into the same location as your production code.
So, you would place all of your test classes inside of src/test
, and all of your production code into src/main
.

Makoto
- 104,088
- 27
- 192
- 230