The workaround would be to have datasources within each
test class specific to the request and let them pass the
required key to a central routine that manages the spreadsheet.
I suggest you add a feature request for parameterized test case
sources at http://bugs.launchpad.net/nunit-3.0
Charlie
> --
> You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
> To post to this group, send email to nunit-...@googlegroups.com.
> To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class TestCaseSourceEx : TestCaseSourceAttribute
{
public TestCaseSourceEx(Type sourceType, string sourceName, [CallerMemberName] string methodName = null)
: base(sourceType, sourceName)
{
}
public TestCaseSourceEx(string sourceName, [CallerMemberName] string methodName = null)
: base(sourceName)
{
}
}
[TestFixture]
public class SampleTests
{
public IEnumerable List = new[] { new string[] { "test-username", "test-password" } };
[Test, TestCaseSourceEx("List")]
public void SampleTests_LoginTest(string username, string password)
{
}
}<TestFixture(), TestFixtureSource("FixtureParms")> _
Public Class AllTests
Public Shared strScriptName As String
<OneTimeSetUp> _
Public Sub fixtureSetup()
MsgBox("In FixtureSetup")
End Sub
Sub New(ByVal str As String)
MsgBox("In New")
strScriptName = str
End Sub
<Test(), TestCaseSource("TestCases")> _
Public Shared Sub start()
ExecuteTestFlow()
End Sub
''' Function will fetch data from excel file and will return Enumerable object of all the TestCases
''' Now this function will be called for each fixture separately. But we are not getting any way to pass the fixture parameter to it. So ''' the generateTestCaesfromXLFile is getting null parameter and its reading all the files to construct TestCases.
Public Shared Property TestCases() As IEnumerable(Of TestCaseData)
Get
Return (generateTestCasesfromXLFile(strFileName))
End Get
End Property
''' Function will read all excel file names from RunTime folder and will create a seperate fixture for each file.
Public Shared Property FixtureParms As IEnumerable(Of TestFixtureData)
Get
Dim oList As New List(Of TestFixtureData)
Dim oDirectoryInfo As New DirectoryInfo("c:\seleniumLive\RunTime\")
For Each ofile As FileInfo In oDirectoryInfo.GetFiles("*.xlsx", SearchOption.TopDirectoryOnly)
oList.Add(New TestFixtureData(ofile.FullName))
Next
Return oList
End Get
End Property
End Class
Below is the nUnit 3 screenshot.