Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a clean way to run all unit tests multiple times with different regional settings #42

Closed
tpierrain opened this issue Apr 23, 2013 · 6 comments
Assignees
Labels
Milestone

Comments

@tpierrain
Copy link
Owner

So that we won't encounter regional settings related issues.

@malat
Copy link
Collaborator

malat commented Apr 26, 2013

@dupdob
Copy link
Collaborator

dupdob commented Apr 27, 2013

I have implemented an helper function that runs all present nUnit tests (using reflection). One just has to wrap them with SetCultureAttribute. See in LocaleCheck.cs

        [Test]
        [SetCulture("fr-CA")]
        public void CanadianFrench()
        {
            RunnerHelper.RunAllTests();
        }

I guess you will be able to close this one.

@malat
Copy link
Collaborator

malat commented Apr 28, 2013

That was fast ;-)

But what about time zone ?

I haven't find a clean way to handle that unless you always use UTC for date time related test otherwise expected exception test will failed since local date time string will be different...

Great job by the way!

@malat
Copy link
Collaborator

malat commented May 10, 2013

I think it may be possible to introduce a DateTime formater that will format all unspecified/locale date kind to a specific locale+ timezone like in java Joda time.

http://stackoverflow.com/questions/10833948/make-unit-tests-with-dates-pass-in-all-time-zones-and-with-out-dst

Do you think we should POC this kind of solution ? I could go deeper on that if you want....

@dupdob
Copy link
Collaborator

dupdob commented May 10, 2013

Hello Marc-Antoine,
Can you explain what you plan to achieve through that?
I am asking that only because I link your proposal to multiple ideas:

1: Do not add constraints to NFluent implementors:

  • only requirements are .Net 3.5 at least and a Windows platform (for now)
  • NFluent shall work whatever the project settings may be, including
    languages and locale specifics

2: Help contributors (us) achieve those objectives
The tests I added are here to help us make sure there is no hidden
dependency in NFluent regarding the language. It remains to be done for
other regional settings, such as date format

3: ultimately, help NFluent implementors implement locale insensitive code
themselves

Regartim item 2, I think we have to avoid any specific test were we force
the locale and/or formats: any such test will only prove the code works in
one specific locale!!
It problably means we need to change how we need to replace
ExpectedException by a more adequate pattern.

Your thoughts?

Le vendredi 10 mai 2013, Marc-Antoine Latour a écrit :

I think it may be possible to introduce a DateTime formater that will
format all unspecified/locale date kind to a specific locale+ timezone like
in java Joda time.

http://stackoverflow.com/questions/10833948/make-unit-tests-with-dates-pass-in-all-time-zones-and-with-out-dst

Do you think we should POC this kind of solution ? I could go deeper on
that if you want....


Reply to this email directly or view it on GitHubhttps://github.com//issues/42#issuecomment-17702723
.

Envoyé depuis mon IPad

@malat
Copy link
Collaborator

malat commented May 10, 2013

Hi Cyrille,

What I try to achieve is to be able to support DateTime kind local properly, by now all related DateTime test are using UTC or unspecified date kind since locale date time will have different representation depending of your time zone and will make some unit test failing if the test is using the expectedexception message attribute (me and Thomas was playing ping/pong with those test ;-) works in Montreal but not in Paris or viceversa).

Also, another requirement is to support string as input for date time (issue #28), thus, it will be hard to run those test with multiple culture since it could dramatically change the input string format.

So I was thinking that maybe we could allowed the developer to force a specific format using this kind of syntax : Check.That(new DateTime(2000,1,1)).UsingFormat("MM/dd/YYYY").IsBefore("01/1/2001")

It's is more a brainstorming than a proposal, since I plan to work on the issue #28 shortly

Best regards

Sent from my iPad

On 2013-05-10, at 4:14, "Cyrille DUPUYDAUBY" [email protected] wrote:

Hello Marc-Antoine,
Can you explain what you plan to achieve through that?
I am asking that only because I link your proposal to multiple ideas:

1: Do not add constraints to NFluent implementors:

  • only requirements are .Net 3.5 at least and a Windows platform (for now)
  • NFluent shall work whatever the project settings may be, including
    languages and locale specifics

2: Help contributors (us) achieve those objectives
The tests I added are here to help us make sure there is no hidden
dependency in NFluent regarding the language. It remains to be done for
other regional settings, such as date format

3: ultimately, help NFluent implementors implement locale insensitive code
themselves

Regartim item 2, I think we have to avoid any specific test were we force
the locale and/or formats: any such test will only prove the code works in
one specific locale!!
It problably means we need to change how we need to replace
ExpectedException by a more adequate pattern.

Your thoughts?

Le vendredi 10 mai 2013, Marc-Antoine Latour a écrit :

I think it may be possible to introduce a DateTime formater that will
format all unspecified/locale date kind to a specific locale+ timezone like
in java Joda time.

http://stackoverflow.com/questions/10833948/make-unit-tests-with-dates-pass-in-all-time-zones-and-with-out-dst

Do you think we should POC this kind of solution ? I could go deeper on
that if you want....


Reply to this email directly or view it on GitHubhttps://github.com//issues/42#issuecomment-17702723
.

Envoyé depuis mon IPad

Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants