Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: =?UTF-8?Q?Re:_What_is_the_=e2=80=98standard=e2=80=99_when_using_a_c?= =?UTF-8?Q?onstant_in_several_unit_tests?= Date: Sat, 19 Aug 2017 20:07:27 -0400 Organization: Aioe.org NNTP Server Lines: 21 Message-ID: References: <87k21zh319.fsf@munus.decebal.nl> <8760djgxj6.fsf@munus.decebal.nl> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:37308 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. Arne PS: He recommends a private constructor to prevent instantiation.