Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: What is the =?utf-8?B?4oCYc3RhbmRhcmTigJk=?= when using a constant in several unit tests Date: Sun, 20 Aug 2017 04:43:38 +0200 Organization: Decebal Computing Lines: 30 Message-ID: <87efs7ez6t.fsf@munus.decebal.nl> References: <87k21zh319.fsf@munus.decebal.nl> <8760djgxj6.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="a3233d099e71e24d901953f13bac9801"; logging-data="10086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18C9rpjFzbfYgEPjsdJIsGiHMTHuQ+8XsI=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:RvOzk6x/Obk0BRNGlnVwRq3gt4A= sha1:l8yNHR/o/F5TwcyTTVCgzjxF7AY= X-Homepage: http://www.decebal.nl/ Xref: csiph.com comp.lang.java.programmer:37309 Arne Vajhøj writes: > On 8/19/2017 3:36 PM, Cecil Westerhof wrote: >> ram@zedat.fu-berlin.de (Stefan Ram) writes: >>> Cecil Westerhof writes: >>>> I have several test classes that have the following constant: >>>> private static final String TEST_DB = "testDB.sqlite"; >>>> Is this the way to do it, or should it be put centrally? >>> >>> You can put it into an extra class: >>> >>> public final class TestConstants >>> { public static final java.lang.String TEST_DB = "testDB.sqlite"; } >> >> That is not frowned upon? > > No. Well maybe. But Joshua Bloch recommends it in "Effective Java". So > you can certainly defend the approach. OK, thanks. > PS: He recommends a private constructor to prevent instantiation. That I always do with a class that should not be initiated. ;-) -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof