Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37308

Re: What is the ‘standard’ when using a constant in several unit tests

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: What is the ‘standard’ when using a constant in several unit tests
Date 2017-08-19 20:07 -0400
Organization Aioe.org NNTP Server
Message-ID <onajs2$1pd2$1@gioia.aioe.org> (permalink)
References <87k21zh319.fsf@munus.decebal.nl> <global-constant-20170819191602@ram.dialup.fu-berlin.de> <8760djgxj6.fsf@munus.decebal.nl>

Show all headers | View raw


On 8/19/2017 3:36 PM, Cecil Westerhof wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>> Cecil Westerhof <Cecil@decebal.nl> 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.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What is the ‘standard’ when using a constant in several unit tests Cecil Westerhof <Cecil@decebal.nl> - 2017-08-19 19:37 +0200
  Re: What is the ‘standard’ when using a constant in several unit tests Cecil Westerhof <Cecil@decebal.nl> - 2017-08-19 21:36 +0200
    Re: What is the ‘standard’ when using a constant in several unit tests Arne Vajhøj <arne@vajhoej.dk> - 2017-08-19 20:07 -0400
      Re: What is the ‘standard’ when using a constant in several unit tests Cecil Westerhof <Cecil@decebal.nl> - 2017-08-20 04:43 +0200
  Re: What is the ‘standard’ when using a constant in several unit tests Arne Vajhøj <arne@vajhoej.dk> - 2017-08-19 20:03 -0400
  Re: What is the ???standard??? when using a constant in several unit tests leif.roar@dimnakorr.com - 2017-08-20 04:36 -0500
    Re: What is the ???standard??? when using a constant in several unit tests Cecil Westerhof <Cecil@decebal.nl> - 2017-08-20 12:21 +0200
  What is the ‘standard’ when using a constant in several unit tests lewbloch@gmail.com - 2017-08-20 09:46 -0700
    Re: What is the ‘standard’ when using a constant in several unit tests Arne Vajhøj <arne@vajhoej.dk> - 2017-08-20 13:12 -0400

csiph-web