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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Mar 11, 2010, 12:16 PM EST
Can you explain where you got the files from? How are they being used currently?
j l68 reputationPosted Mar 11, 2010, 2:05 PM EST
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 HobbsRank #107 · 20.5K reputationPosted Mar 11, 2010, 2:19 PM EST
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 l68 reputationPosted Mar 12, 2010, 4:08 AM EST
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