Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to call non static method of base class from static [TestCleanup] method of derived class
    primarykey
    data
    text
    <p>Background : </p> <p>I'm working on a Visual Studio 2010 test project for UI testing using Selenium web driver underlying. For which,</p> <p>I have defined [TestClass] named <em>TestCases</em> which is derived from <em>base</em> <strong>TestUtil</strong> class which contains some generic utilities to accept test configuraiont data.</p> <p>Problem: </p> <p>I need to generate Test report after successful completion of <strong>all</strong> test cases execution. Thus, I've decided to put all reporting activities related code in my <em>[ClassCleanup]</em> method.</p> <p>Actual problem is, A part of the reporting code actually depends on Config parameters from <em>base</em> <strong>TestUtil</strong> class. But since, My <em>[ClassCleanup]</em> method is <strong>Static</strong>, I'm not able to access all config parameters in my <em>[ClassCleanup]</em> reporting activities code.</p> <p>My <em>TestClass</em> looks like: </p> <pre><code> [TestClass] public class TestCases : TestCaseUtil { Browser browser; int stepNo; private static string configFilesLocation = String.Empty; //private static string /// &lt;summary&gt; /// Defines test context /// &lt;/summary&gt; private TestContext testContextInstance; /// &lt;summary&gt; ///Gets or sets the test context which provides ///information about and functionality for the current test run. ///&lt;/summary&gt; public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } } /// &lt;summary&gt; /// TestCases Class Constructor /// &lt;/summary&gt; public TestCases() { // Loads config data and creates a Singleton object of Configuration and loads data into generic test case variables GetConfigData(); /// Get debug viewer exe file path configFilesLocation = PrepareConfigureDataFilePath(); /// Prepare log directory details from xml file PrepareLogDirectoryPath(configFilesLocation); /// Initialize browser instance browser = null; applicationLog = null; stepNo = 1; } /// &lt;summary&gt; /// Test case to verify if create module and corresponding event works fine. /// &lt;/summary&gt; [Ignore] [TestMethod, Description("Test case to verify if create module and corresponding event works fine.")] public void CreateAndVerifyEvent() { ///Test in Progress } /// &lt;summary&gt; **/// Test clean up activities** /// &lt;/summary&gt; [TestCleanup] public void Cleanup() { **/// Test Clean up activities here** } /// &lt;summary&gt; **/// Test Class cleanup activities here** /// &lt;/summary&gt; [ClassCleanup] public static void TestClassCleanupClass() { **/// This is **Reporting Code**** try { **/// This code contains methods call and variable call from Base class (TestUtils), Which are obviously not working since Base class is not static class.** string ExecutionStartDateTime = GetValuesFromXML("TestDataConfig", "ExecutionStartDateTime", configFilesLocation + "\\RunTime.xml"); //startTimeOfExecution = Convert.ToDateTime(ExecutionStartDateTime.ToString()); //endTimeOfExecution = DateTime.Now; // Generate custome html report form csv logs AutomationReport automationReport = new AutomationReport(logFileDirectory, reportFileDirectory, server, Convert.ToDateTime(ExecutionStartDateTime.ToString()), DateTime.Now); embeddedMailContents = automationReport.CompileReportFromCSV(); // Prepare path for zip file string zippedFolderPath = reportFileDirectory + ".zip"; // Zip the custome html report folder FileZipOperations fileZipOperations = new FileZipOperations(reportFileDirectory, zippedFolderPath, null); fileZipOperations.ZipFiles(); } catch (Exception e) { Console.WriteLine("Test Clean not succeed" + e.Message); } finally { } } } } </code></pre> <ol> <li>My Base Class is simple Non-static class with few configuration utilities.</li> <li>My Reporting class is a different that too non static and simple one.</li> </ol> <p>Is there any way i can call all non static function and variable from <em>STATIC</em> *[ClassCleanup]* method? or any other way i can achieve the same?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload