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); }
public void SetUp() { // Define test case types mimicking TestRail. Should only have one default type. var testCaseTypes = new List <TestCaseTypeModel> { new TestCaseTypeModel { Id = 1, Name = "Regression", IsDefault = false }, new TestCaseTypeModel { Id = 2, Name = "Other", IsDefault = true }, new TestCaseTypeModel { Id = 3, Name = "Smoke", IsDefault = false } }; // Read the files _nunitFileController = new NunitFileController(); _nunit3TestCases = _nunitFileController.GetTestsFromNunit3File(Nunit3TestCasesFile, testCaseTypes); _nunit3TestResults = _nunitFileController.GetTestsFromNunit3File(Nunit3TestResultsFile, testCaseTypes); // Define expected test cases. Results are included by default, but are removed based on this test's params. _testCases = new List <TestCaseModel> { new TestCaseModel { FixtureFullName = "Specs.Features.Account", FixtureName = "Login", Title = "LogInWithValidCredentials", Tags = "automated,browser,smoke", IsAutomated = true, TypeId = 3, TestResult = new TestResultModel { Result = "Passed", Duration = "7.103904", ErrorMessage = "", Attachments = new List <TestResultAttachmentModel>(), }, }, new TestCaseModel { FixtureFullName = "Specs.Features.Account", FixtureName = "Login", Title = "LogInWithInvalidCredentials(\"Blank UserName\",\"\",\"password12\",\"The User Name field is required.\",null)", Tags = "automated,browser,regression", IsAutomated = true, TypeId = 1, TestResult = new TestResultModel { Result = "Passed", Duration = "7.567879", ErrorMessage = "", Attachments = new List <TestResultAttachmentModel>(), }, }, new TestCaseModel { FixtureFullName = "Specs.Features.Account", FixtureName = "Login", Title = "LogInWithInvalidCredentials(\"Blank Password\",\"test.user\",\"\",\"The Password field is required.\",null)", Tags = "automated,browser,regression", IsAutomated = true, TypeId = 1, TestResult = new TestResultModel { Result = "Passed", Duration = "6.300555", ErrorMessage = "", Attachments = new List <TestResultAttachmentModel>(), }, }, new TestCaseModel { FixtureFullName = "Specs.Features.Agent", FixtureName = "Agent EFT Info", Title = "CancelAddingNewAgentEFTInfo", Tags = "automated,browser", IsAutomated = true, TypeId = 2, TestResult = new TestResultModel { Result = "Passed", Duration = "42.278604", ErrorMessage = "", Attachments = new List <TestResultAttachmentModel>(), }, }, new TestCaseModel { FixtureFullName = "Specs.Features.Agent", FixtureName = "Agent EFT Info", Title = "EditAgentEFTInfo", Tags = "automated-skip,browser,regression", IsAutomated = false, TypeId = 1, TestResult = new TestResultModel { Result = "Passed", Duration = "43.204554", ErrorMessage = "", Attachments = new List <TestResultAttachmentModel>(), }, }, new TestCaseModel { FixtureFullName = "Specs.ServiceTests.Extracts", FixtureName = "EZB Connector", Title = "GenerateExtractsWithVariousEligibilityScenarios", Tags = "app-server,automated,ezb,regression,shared-test-group-TEST0001,writes-to-database", IsAutomated = true, TypeId = 1, TestResult = new TestResultModel { Result = "Failed", Duration = "2217.758296", ErrorMessage = "Expected something but got something else.\n\nstack trace here", Attachments = new List <TestResultAttachmentModel> { new TestResultAttachmentModel { FilePath = @"C:\Windows\Web\Wallpaper\Theme1\img1.jpg", Description = "Screenshot" }, new TestResultAttachmentModel { FilePath = @"C:\Windows\Web\Wallpaper\Theme1\img2.jpg" } }, }, }, }; }