SplitTestcases() public method

public SplitTestcases ( ) : List>
return List>
        private void ExecuteRandomDurationsTest(int nrOfTests, int maxRandomDuration, int nrOfThreads)
        {
            IDictionary <Model.TestCase, int> durations = CreateRandomTestResults(nrOfTests, maxRandomDuration);

            MockOptions.Setup(o => o.MaxNrOfThreads).Returns(nrOfThreads);

            ITestsSplitter splitter = new DurationBasedTestsSplitter(durations, TestEnvironment.Options);
            List <List <Model.TestCase> > result = splitter.SplitTestcases();

            result.Count.Should().Be(nrOfThreads);
            result.Select(l => l.Count).Sum().Should().Be(nrOfTests);

            int sumOfAllDurations = durations.Select(kvp => kvp.Value).Sum();
            int maxDuration       = durations.Select(kvp => kvp.Value).Max();

            int targetDuration = sumOfAllDurations / nrOfThreads;

            HashSet <Model.TestCase> foundTestcases = new HashSet <Model.TestCase>();

            foreach (List <Model.TestCase> testcases in result)
            {
                int sum = testcases.Select(tc => durations[tc]).Sum();
                sum.Should().BeLessThan(targetDuration + maxDuration / 2);
                sum.Should().BeGreaterThan(targetDuration - maxDuration / 2);

                foundTestcases.UnionWith(testcases);
            }

            foundTestcases.Count.Should().Be(nrOfTests);
        }
        public void SplitTestcases_AsymmetricCase_TestsAreDistributedCorrectly()
        {
            IDictionary<Model.TestCase, int> durations = new Dictionary<Model.TestCase, int>();
            durations.Add(TestDataCreator.ToTestCase("ShortTest1"), 1);
            durations.Add(TestDataCreator.ToTestCase("LongTest"), 5);

            MockOptions.Setup(o => o.MaxNrOfThreads).Returns(3);

            ITestsSplitter splitter = new DurationBasedTestsSplitter(durations, TestEnvironment);
            List<List<Model.TestCase>> result = splitter.SplitTestcases();

            result.Count.Should().Be(2);
            result[0].Count.Should().Be(1);
            result[0][0].FullyQualifiedName.Should().Be("LongTest");
            result[1].Count.Should().Be(1);
        }
Example #3
0
        public void SplitTestcases_AsymmetricCase_TestsAreDistributedCorrectly()
        {
            IDictionary <Model.TestCase, int> durations = new Dictionary <Model.TestCase, int>();

            durations.Add(ToTestCase("ShortTest1"), 1);
            durations.Add(ToTestCase("LongTest"), 5);

            MockOptions.Setup(o => o.MaxNrOfThreads).Returns(3);

            ITestsSplitter splitter = new DurationBasedTestsSplitter(durations, TestEnvironment);
            List <List <Model.TestCase> > result = splitter.SplitTestcases();

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(1, result[0].Count);
            Assert.AreEqual("LongTest", result[0][0].FullyQualifiedName);
            Assert.AreEqual(1, result[1].Count);
        }
        public void SplitTestcases_AsymmetricCase_TestsAreDistributedCorrectly()
        {
            IDictionary <Model.TestCase, int> durations = new Dictionary <Model.TestCase, int>();

            durations.Add(TestDataCreator.ToTestCase("ShortTest1"), 1);
            durations.Add(TestDataCreator.ToTestCase("LongTest"), 5);

            MockOptions.Setup(o => o.MaxNrOfThreads).Returns(3);

            ITestsSplitter splitter = new DurationBasedTestsSplitter(durations, TestEnvironment.Options);
            List <List <Model.TestCase> > result = splitter.SplitTestcases();

            result.Should().HaveCount(2);
            result[0].Should().ContainSingle();
            result[0][0].FullyQualifiedName.Should().Be("LongTest");
            result[1].Should().ContainSingle();
        }
        public void SplitTestcases_SimpleCaseWithThreeThreads_TestsAreDistributedCorrectly()
        {
            IDictionary <Model.TestCase, int> durations = new Dictionary <Model.TestCase, int>();

            durations.Add(TestDataCreator.ToTestCase("ShortTest1"), 1);
            durations.Add(TestDataCreator.ToTestCase("ShortTest2"), 1);
            durations.Add(TestDataCreator.ToTestCase("LongTest"), 3);
            durations.Add(TestDataCreator.ToTestCase("ShortTest3"), 1);

            MockOptions.Setup(o => o.MaxNrOfThreads).Returns(3);

            ITestsSplitter splitter = new DurationBasedTestsSplitter(durations, TestEnvironment);
            List <List <Model.TestCase> > result = splitter.SplitTestcases();

            result.Count.Should().Be(3);
            result[0].Count.Should().Be(1);
            result[0][0].FullyQualifiedName.Should().Be("LongTest");
            result[1].Count.Should().Be(2);
            result[2].Count.Should().Be(1);
        }
        private void ExecuteRandomDurationsTest(int nrOfTests, int maxRandomDuration, int nrOfThreads)
        {
            IDictionary<Model.TestCase, int> durations = CreateRandomTestResults(nrOfTests, maxRandomDuration);

            MockOptions.Setup(o => o.MaxNrOfThreads).Returns(nrOfThreads);

            ITestsSplitter splitter = new DurationBasedTestsSplitter(durations, TestEnvironment);
            List<List<Model.TestCase>> result = splitter.SplitTestcases();

            result.Count.Should().Be(nrOfThreads);
            result.Select(l => l.Count).Sum().Should().Be(nrOfTests);

            int sumOfAllDurations = durations.Select(kvp => kvp.Value).Sum();
            int maxDuration = durations.Select(kvp => kvp.Value).Max();

            int targetDuration = sumOfAllDurations / nrOfThreads;

            HashSet<Model.TestCase> foundTestcases = new HashSet<Model.TestCase>();
            foreach (List<Model.TestCase> testcases in result)
            {
                int sum = testcases.Select(tc => durations[tc]).Sum();
                sum.Should().BeLessThan(targetDuration + maxDuration / 2);
                sum.Should().BeGreaterThan(targetDuration - maxDuration / 2);

                foundTestcases.UnionWith(testcases);
            }

            foundTestcases.Count.Should().Be(nrOfTests);
        }