I have 2 test files (.cs) independent from each other
Is there a way to reference test file 1 (and pass all its variables values) into test file 2?
Im using C# code only.
thanks
J
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
j lPosted Mar 12, 2010, 9:08 AM
Example:
namespace WorldSales
[TestClass]
public class Sales
{
I initialize some variables here & I setup the MyClassInitialize Class here...
e.g. Private Static bool AllResultsAreOK = false;
e.g. ExcelApp = new Microsoft.Office.Interop.Excel.Application();
I also setup the TestCleanUp Class here
}
[Test Method]
public void T_SalesLookup()
{
Here I begin using the Excel Interop library to control sheets/workbooks/tabs/colors
I begin comparing my static Excel values to values received from a server
e.g. Assert.IsTrue(CompareResult);
Depending on the compare results, I increment counters inttotalPassed++ , inttotalFailed++, intTotal = inttotalPassed + inttotalFailed
If there were no fails,
{ Set AllResultsAreOK = true;
}
Else Assert.False ("There was a failure)
}
Now, what I want to do is have a 2nd .cs file that knows about the variables mentioned above inttotalPassed, inttotalFailed, intTotal, and AllResultsAreOK
I hope this is what you are looking for.
~J
Sam HobbsPosted Mar 11, 2010, 7:19 PM
The term "unit test" as in "unit test files" usually refer to test data, not code. Also, the term "solution" is ambiguous in the sense that two cs files can be for one application or two applications. It is very difficult to know how to describe what you need to do. If you can answer the questions in my first reply, that will help. We need more information somehow.
j lPosted Mar 11, 2010, 7:05 PM
I have 2 unit test files within 1 solution.
Once the first .cs file completes, I want to run the 2nd .cs file.
All I want to do is have the 2nd .cs file use some of the same methods, variables and (if possible) values from the 1st .cs file.
Do I need to use a "using statement" e.g. "Using 1st file.cs"?
Do I need to use some other code to call methods from 1st cs file??
Just looking for some code ideas
thanks
J
Sam HobbsPosted Mar 11, 2010, 5:16 PM
Can you explain where you got the files from? How are they being used currently?