Please consider change DefaultDelimiters in Spring.Testing from Semicolon to Comma

Issue #245 resolved
Zuo Baoquan created an issue
  1. To align with Delphi language. COMMA is used when passing arguments, SEMICOLON is used to declare parameters. Neither of them are perfect but I think Comma is better suited.

  2. It is also compatible with DUnitX. (Less trouble when transition)

  3. The plural name implies that more than one delimiter could be supported. I suggest change it as single delimiter. If we choose Comma, ; can/should be used to in other cases. e.g.

procedure Test(strings: TStrings; values: array of string; connectionStringDelimiteredBySemicolon: string);

Comments (3)

  1. Stefan Glienke repo owner
    • changed status to open

    There is more to it than just comma vs semicolon. Currently the strings being converted to the proper data type are using the global format settings which makes the code being affected by the DecimalSeparator setting which in some regions is the comma (I remember DUnitX having the same problem which they could easily solve by hardcoding it to always use a formatsettings with DecimalSeparator set to the dot). We cannot do that because the code that runs here is using TValueHelper.Convert which as I said uses the currently set format settings. So what we need here is the same code being used in TValue.Convert (which is quite complex) using a passed formatSettings. This will not only affect float numbers by the way but also dates and times being passed to a TestCase attribute as string.

    I really like to fix this misbehavior as unit tests should not be affected by the current regional settings when it comes to input data. Dates and times should also be passed in ISO 8601 format to make it behave the same on all systems.

  2. Zuo Baoquan reporter

    Ah, I forgot these stuff. Basically, there are two parts: 1. how to separate arguments 2. how to convert/pass the value of arguments. About the first one, I actually used some overloads rather than a single delimited string (which doesn't save too much).

    TestCaseAttribute = class(xx)
    constructor Create(const arg1: string); overload;  // match single parameter
    constructor Create(const arg1, arg2: string); overload;
    constructor Create(const arg1, arg2, arg3: string); overload;
    // arg1...arg7
    end;
    

    I also like to create specific derived attribute types to benefit from strong type/refactoring. (enum, etc.) especially when there are many test cases.

    Second. As you said, test should not be affected by the formatting settings in general. I would think those test data similar to JSON. I just hope there is a clearly defined "specification" which explains the conversion and possible extension (e.g. apply attributes to method or params -- no need now^_^). then I just follow it. (For me, I mostly use integer/string/enum.)

  3. Log in to comment