private static int Main(string[] args) { // Parse command line arguments var commandLineArgumentParser = new CommandLineArgumentParser(); var options = new Options(); var areCommandLineArgumentsValid = commandLineArgumentParser.Parse(args, options); var areOptionsValid = AreOptionsValid(options); // Proceed with application if options are valid if (areCommandLineArgumentsValid && areOptionsValid) { // Output run options options.PrintOptions(); try { // Initialize TestRail controller var testRailApiController = new TestRailApiController( options.TestRailUrl, options.TestRailUserEmail, options.TestRailPassword, options.TestRailProjectId); // Test the TestRail API connection testRailApiController.TestConnection(); // Initialize TestSync controller var nunitController = new NunitFileController(); var testSyncController = new TestSyncController(nunitController, testRailApiController, RootSectionName); // Ensure Root section exists for TestRail project testSyncController.InitializeRootSectionInTestRail(); // Sync Test Cases if (options.ShouldSyncTestCases) { testSyncController.SyncTestCases(options.NunitTestCasesFile); } // Sync Test Results if (options.ShouldSyncTestResults) { testSyncController.SyncTestResults(options.NunitTestResultsFile, options.TestRailRunName); } Console.WriteLine(); Console.WriteLine("TestRail-NUnit-Sync completed successfully."); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(); Console.WriteLine("TestRail-NUnit-Sync completed unsuccessfully."); return(1); } } return(0); }
public void SetUp() { // Section shared by multiple TestRail cases var section = new SectionModel { Id = 3, ParentId = 2, RootSectionId = 1, Name = "Login", Description = "", Depth = 2, }; // Define TestRail cases _testRailCases = new List <TestCaseModel> { new TestCaseModel { Id = 1, Title = "Invalid user login", Section = section, SectionId = section.Id, IsAutomated = true, TypeId = 1, }, new TestCaseModel { Id = 2, Title = "Valid user login", Section = section, SectionId = section.Id, IsAutomated = true, TypeId = 1, }, }; // Initialize Controllers var nunitFileController = new NunitFileController(); var testRailApiController = new TestRailApiController("", "", "", ""); const string rootSectionName = "SyncTest"; _testSyncController = new TestSyncController(nunitFileController, testRailApiController, rootSectionName); }