Bugs item #995409, was opened at 2004-07-21 12:39
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=995409&group_id=31650

Category: Tasks
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tom Cabanski (tcabanski)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improvement to NUNit2

Initial Comment:
I�ve run into a situation where I have to run my unit test 
suite under a number of cultures to verify proper 
handling of number and date formatting.� Rather that 
manually switching my machine for each test, I�ve 
introduced a culture attribute to the test element of the 
nunit2 task.� For example, the following directive runs 
my test suite in five cultures:

<target name="unitTestLanguages" depends="prep, 
build" description="Runs unit tests under additional 
languages.">
����������� <nunit2 failonerror="false">
����������������� <test assemblyname="${test.dir}
\jdp.tests.dll" appconfig="${test.dir}\jdp.tests.dll.config" 
culture="it-IT"/>
����������������� <test assemblyname="${test.dir}
\jdp.tests.dll" appconfig="${test.dir}\jdp.tests.dll.config" 
culture="fr-FR"/>
����������������� <test assemblyname="${test.dir}
\jdp.tests.dll" appconfig="${test.dir}\jdp.tests.dll.config" 
culture="de-DE"/>
����������������� <test assemblyname="${test.dir}
\jdp.tests.dll" appconfig="${test.dir}\jdp.tests.dll.config" 
culture="en-GB"/>
����������������� <test assemblyname="${test.dir}
\jdp.tests.dll" appconfig="${test.dir}\jdp.tests.dll.config" 
culture="zh-CN"/>
����������� </nunit2>
����� </target>

We've had this for several months now and found it 
quite useful.� As a result, I got the latest code from CVS 
and added the new attribute to it.

Here�s the diff from CVS:

Index: NUnit2Task.cs
==========================================
=========================
RCS 
file: /cvsroot/nant/nant/src/NAnt.NUnit/NUnit2/NUnit2Ta
sk.cs,v
retrieving revision 1.37
diff -r1.37 NUnit2Task.cs
107a108,118
>���� ///��� <para>
>���� ///�� Run tests in the <c>MyProject.Tests.dll</c> 
assembly using the Italian culture (even if the computer 
is using a different culture).
>���� ///�� </para>
>���� ///�� <code>
>���� ///���� <![CDATA[
>���� /// <nunit2>
>���� ///���� <formatter type="Plain" />
>���� ///���� <test assemblyname="MyProject.Tests.dll" 
>appconfig="MyProject.Tests.dll.config" culture="it-IT"/>
>���� /// </nunit2>
>���� ///���� ]]>
>���� ///�� </code>
278a290,298
> ��������������� 
> ��������������� //Save the current culture and set the 
thread's 
> culture based on the default of the Culture attribute
> ��������������� System.Globalization.CultureInfo 
holdCulture = 
> 
System.Threading.Thread.CurrentThread.CurrentCulture;
> ��������������� 
System.Threading.Thread.CurrentThread.CurrentCulture 
= 
> test.CultureInfo;
> 
> ��������������� if (holdCulture.Name != 
test.CultureInfo.Name)
> ��������������� {
> ��������������������� Console.WriteLine("RUNNING TESTS 
UNDER CULTURE 
> {0}", test.CultureInfo.Name);
> ��������������� }
287a308,310
> ��������������� //Put back the old culture
> ��������������� 
System.Threading.Thread.CurrentThread.CurrentCulture 
= 
> holdCulture;
> 
Index: NUnit2Test.cs
==========================================
=========================
RCS 
file: /cvsroot/nant/nant/src/NAnt.NUnit/NUnit2/NUnit2Te
st.cs,v
retrieving revision 1.23
diff -r1.23 NUnit2Test.cs
44a45
> ��������� private System.Globalization.CultureInfo 
_culture = 
> System.Globalization.CultureInfo.CurrentCulture;
106a108,127
> ��������� /// <summary>
> ��������� /// Set to a culture name such as "fr-FR" 
(France French)
> ��������� /// to run the tests under a culture other than
> ��������� /// the machine default culture.
> ��������� /// </summary>
> ��������� [TaskAttribute("culture")]
> ��������� public string Culture
> ��������� {
> ��������������� get { return _culture.Name; }
> ��������������� set { _culture = new
> System.Globalization.CultureInfo(value); }
> ��������� }
> 
>�������� /// <summary>
>�������� /// The CultureInfo object which will be used to 
set the culture of the test.
>�������� /// </summary>
>�������� public System.Globalization.CultureInfo 
CultureInfo
>�������� {
>������������ get { return _culture; }
>�������� }
> 

***** CVS exited normally with code 1 *****

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=995409&group_id=31650


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to