private ITestable GetTestable(WorkItem workItem, TestcaseProvider testcaseProvider) { object branchSpecificFileLock = _testFileLocker.GetLock(workItem.Testsystem.Name); lock (branchSpecificFileLock) { ITestable testable = testcaseProvider.GetTestableFromTypeName(workItem.Testcase.Type); return(testable); } }
void IBuildTaskService.SendTestcaseFile(string testsystemName, byte[] data) { object _lock = _testFileLocker.GetLock(testsystemName); lock (_lock) { Testsystem testsystem = _testsystemRepository.GetByName(testsystemName); testsystem.LastUpdated = DateTime.Now; _testsystemRepository.Store(testsystem); string testFile = RegtestingServerConfiguration.Testsfolder + testsystem.Filename; Directory.CreateDirectory(Path.GetDirectoryName(testFile)); using (FileStream fileStream = new FileStream(testFile, FileMode.Create, FileAccess.Write)) { fileStream.Write(data, 0, data.Length); } Logger.Log("UPDATE branch: " + testsystemName); TestcaseProvider testcaseProvider = new TestcaseProvider(testFile); testcaseProvider.CreateAppDomain(); foreach (string testcaseType in testcaseProvider.Types) { ITestable testable = testcaseProvider.GetTestableFromTypeName(testcaseType); if (testable == null) { continue; } Testcase testcase = _testcaseRepository.GetByType(testcaseType); string testableName = testable.GetName(); if (testcase == null) { Logger.Log("New test: " + testableName); testcase = new Testcase { Name = testableName, Type = testcaseType }; _testcaseRepository.Store(testcase); } else if (!testcase.Name.Equals(testableName)) { Logger.Log("Renamed test: " + testcase.Name + " to " + testableName); testcase.Name = testableName; _testcaseRepository.Store(testcase); } } testcaseProvider.Unload(); } }
/// <summary> /// Start a Test and throw exception in errorcase /// </summary> /// <param name="typeName">typename of testcase to load</param> /// <param name="testsystem">string with the testsystem</param> /// <param name="language">string with the language</param> /// <param name="browser"></param> internal void InitializeTest(string typeName, string testsystem, string language, Browser browser) { TestHeader = String.Format("Testcase: {0} ({1}, {2}) on {3}", typeName, language, browser, testsystem); _testable = _testcaseProvider.GetTestableFromTypeName(typeName); _testable.GetLogLastTime(); _testable.SetupTest(WebDriverInitStrategy.SeleniumLocal, browser, testsystem, language); try { _testable.Test(); } catch (TaskCanceledException) { //Test is canceled. Do normal teardown } _testable.TeardownTest(); }
private ITestable LoadTestable(WorkItem workItem) { return(_testcaseProvider.GetTestableFromTypeName(workItem.Testcase.Type)); }
Guid ISlimServerService.AddTestJob(string testsystemName, byte[] data) { var jobGuid = Guid.NewGuid(); string testFile = RegtestingServerConfiguration.Testsfolder + jobGuid + ".dll";; Directory.CreateDirectory(Path.GetDirectoryName(testFile)); using (FileStream fileStream = new FileStream(testFile, FileMode.Create, FileAccess.Write)) { fileStream.Write(data, 0, data.Length); } TestcaseProvider testcaseProvider = new TestcaseProvider(testFile); testcaseProvider.CreateAppDomain(); List <WorkItem> items = new List <WorkItem>(); foreach (string testcaseType in testcaseProvider.Types) { ITestable testable = testcaseProvider.GetTestableFromTypeName(testcaseType); if (testable == null) { continue; } WorkItem workItem = new WorkItem { Browser = new BrowserDto { Browserstring = "phantomjs", Name = "phantomjs" }, Language = new LanguageDto { Name = "Deutsch", Languagecode = "DE" }, Testcase = new TestcaseDto { Name = testable.GetName(), Type = testcaseType }, Testsystem = new TestsystemDto { Filename = jobGuid + ".dll", Name = testsystemName, Url = testsystemName } }; items.Add(workItem); } testcaseProvider.Unload(); TestingJob testingJob = new TestingJob { Guid = jobGuid, ResultCode = TestState.Pending, WaitingWorkItems = items, TestFile = testFile, CurrentWorkItems = new Dictionary <string, WorkItemTask>(), FinishedWorkItems = new List <WorkItem>(), ResultGenerator = new ResultGenerator() }; TestPool.AddTestingJob(testingJob); Console.WriteLine("Added Job " + jobGuid + "(" + testcaseProvider.Types.Count() + " tests) to Testpool."); return(jobGuid); }