Beispiel #1
0
        public static void AssemblyInit()
        {
            EngineSettings.LoadWorkingDirectory(System.IO.Path.GetDirectoryName(typeof(TestStep).Assembly.Location));
            PluginManager.SearchAsync().Wait();
            SessionLogs.Initialize(string.Format("OpenTap.Engine.UnitTests {0}.TapLog", DateTime.Now.ToString("HH-mm-ss.fff")));

            Assembly engine = Assembly.GetAssembly(typeof(ITestStep));

            OpenTap.Log.CreateSource("UnitTest").Info("OpenTAP version '{0}' initialized {1}", PluginManager.GetOpenTapAssembly().SemanticVersion, DateTime.Now.ToString("MM/dd/yyyy"));
        }
Beispiel #2
0
        // This example loads and runs a predefined test plan using the TAP API, the same interface the TAP GUI uses.
        // Use this to create custom GUIs or Operator interfaces. If no GUI is needed, the CLI may be a better alternative.
        // To run this example you must specify a path to a .TapPlan file.

        private static void Main(string[] args)
        {
            Console.WriteLine("\nThis example shows using the TAP API to control loading and running a TestPlan.");

            try
            {
                // If you have plugins in directories different from the location of your TAP_PATH, then add those directories here.
                // PluginManager.DirectoriesToSearch.Add(@"C:\SomeOtherDirectory");

                // Start finding plugins.
                PluginManager.SearchAsync();

                // Point to log file to be used.
                SessionLogs.Initialize("console_log.txt");

                // Determine path to .TapPlan file.
                string absoluteTestPlanPath;
                if (args.Length == 1 && File.Exists(args[0]))
                {
                    absoluteTestPlanPath = args[0];
                }
                else
                {
                    Console.WriteLine("Please specify an absolute path to a .TapPlan file.");
                    return;
                }

                // ResultsListeners are configured by settings files, using the TAP GUI.
                // If settings files do not exist, then a default set of settings files,
                // including a default "Text Log" listener will be used.
                // Alternately, RestultListeners can be configured via TAP API. See the BuildTestPlan.Api example.

                // Load the Test Plan.
                TestPlan myTestPlan = TestPlan.Load(absoluteTestPlanPath);

                // Execute the Test Plan.
                TestPlanRun myTestPlanRun = myTestPlan.Execute();
                Console.WriteLine("Loaded and ran \n{0}", absoluteTestPlanPath);

                // Test Plan properties are accessible.
                Console.WriteLine("TestPlan verdict={0}", myTestPlanRun.Verdict);

                // After the Test Plan has been run Macros, if used, can be expanded.
                SessionLogs.Rename(EngineSettings.Current.SessionLogPath.Expand(date: DateTime.Now));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
            }
            finally
            {
                Console.WriteLine("Press any key to continue.");
                Console.ReadLine();
            }
        }
Beispiel #3
0
        static void Main()
        {
            // If you have plugins in directories different from the location of your TAP_PATH, then add those directories here.
            // PluginManager.DirectoriesToSearch.Add(@"C:\SomeOtherDirectory");

            // Start finding plugins.
            PluginManager.SearchAsync();

            // Point to log file to be used.
            SessionLogs.Initialize("console_log.txt");

            // Create a new Test Plan.
            TestPlan myTestPlan = new TestPlan();

            // All Test Plan steps are added as child steps.
            myTestPlan.ChildTestSteps.Add(new DelayStep {
                DelaySecs = .1, Name = "Delay1"
            });

            // Sequences can be created and added to TestPlan.
            SequenceStep mySequenceStep = new SequenceStep();

            mySequenceStep.ChildTestSteps.Add(new DelayStep {
                DelaySecs = .2, Name = "Delay2"
            });

            LogStep logStep = new LogStep
            {
                Name       = "SomeName",
                LogMessage = "Hello from myTestPlan at " + DateTime.Now.ToLongTimeString(),
                Severity   = LogSeverity.Info
            };

            mySequenceStep.ChildTestSteps.Add(logStep);

            // Sequences are added to the Test Plan like any other step.
            myTestPlan.ChildTestSteps.Add(mySequenceStep);

            // The Test Plan can be saved for later reuse.
            string myFilePath = Path.Combine(AssemblyDirectory, myTestPlan.Name + ".TapPlan");

            myTestPlan.Save(myFilePath);

            // Add any ResultListeners that should be used.
            // If not specified, a list of ResultListeners with a single LogResultListener will be created.
            // Alternatively, the ResultListeners could be defined in settings files.
            List <ResultListener> resultListeners = new List <ResultListener>();

            resultListeners.Add(new LogResultListener());
            //resultListeners.Add(new Keysight.OpenTap.Plugins.Csv.CsvResultListener());

            // Execute the TestPlan. This is the equivalent of the Run button in the TAP GUI.
            myTestPlan.Execute(resultListeners);

            // After the TestPlan has been run Macros, if used, can be expanded.
            SessionLogs.Rename(EngineSettings.Current.SessionLogPath.Expand(date: DateTime.Now));

            Console.WriteLine("This example builds a TestPlan programmatically.");
            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();
        }
Beispiel #4
0
 public static void AssemblyInit()
 {
     EngineSettings.LoadWorkingDirectory(System.IO.Path.GetDirectoryName(typeof(TestStep).Assembly.Location));
     PluginManager.SearchAsync().Wait();
     SessionLogs.Initialize(string.Format("Tap.Package.UnitTests {0}.TapLog", DateTime.Now.ToString("HH-mm-ss.fff")));
 }
Beispiel #5
0
 public void AssemblyInit()
 {
     SessionLogs.Initialize(String.Format("UnitTestLog{0}.txt", DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss")));
 }