コード例 #1
0
        public override void TestRunStarted(Description description)
        {
            SuiteFailed = false;
            TestFailed  = false;
            Scope       = LifecycleScope.SUITE;

            Type targetClass = RandomizedContext.current().TargetClass;

            TestClassesRun.Add(targetClass.Name);
        }
コード例 #2
0
        /// <summary>
        /// Initializes the randomized context for the fixture.
        /// </summary>
        /// <param name="fixture">The test fixture.</param>
        /// <param name="randomizedContext">The randomized context to associate with the fixture.</param>
        /// <returns>The randomized context.</returns>
        public RandomizedContext InitializeTestFixture(Test fixture, RandomizedContext randomizedContext)
        {
            if (fixture is null)
            {
                throw new ArgumentNullException(nameof(fixture));
            }

            fixture.Properties.Set(RandomizedContext.RandomizedContextPropertyName, randomizedContext);
            return(randomizedContext);
        }
コード例 #3
0
        /// <summary>
        /// Sets up the randomized context for both the set up fixture and the test fixture.
        /// We use the same instance for every set up fixture in the assembly, but each test
        /// fixture has its own distinct randomized context instance.
        /// </summary>
        /// <param name="setUpFixture">The setup fixture.</param>
        /// <param name="testFixture">The test fixture.</param>
        private void SetUpRandomizedContext(Test setUpFixture, Test testFixture)
        {
            // Setup the factories so we can read the random seed from the system properties
            LuceneTestCase.SetUpFixture.EnsureInitialized(setUpFixture, testFixture);

            // Reuse the same randomized context for each setup fixture instance, since these all need to report
            // the same seed. Note that setUpFixtureRandomizedContext is static, so we do this once per assembly.
            if (setUpFixtureRandomizedContext is null)
            {
                setUpFixtureRandomizedContext = _randomSeedInitializer.InitializeTestFixture(setUpFixture, testFixture.TypeInfo.Assembly, SETUP_FIXTURE_SEED_OFFSET);
            }
            else
            {
                _randomSeedInitializer.InitializeTestFixture(setUpFixture, setUpFixtureRandomizedContext);
            }

            _randomSeedInitializer.InitializeTestFixture(testFixture, testFixture.TypeInfo.Assembly, TEST_FIXTURE_SEED_OFFSET);
        }
コード例 #4
0
        private void ReportAdditionalFailureInfo(string testName)
        {
            if (TEST_LINE_DOCS_FILE.EndsWith(JENKINS_LARGE_LINE_DOCS_FILE))
            {
                Console.Error.WriteLine("NOTE: download the large Jenkins line-docs file by running " + "'ant get-jenkins-line-docs' in the lucene directory.");
            }

            StringBuilder b = new StringBuilder();

            b.Append("NOTE: reproduce with: ant test ");

            // Test case, method, seed.
            AddVmOpt(b, "testcase", RandomizedContext.current().TargetClass.SimpleName);
            AddVmOpt(b, "tests.method", testName);
            AddVmOpt(b, "tests.seed", RandomizedContext.current().RunnerSeedAsString);

            // Test groups and multipliers.
            if (RANDOM_MULTIPLIER > 1)
            {
                AddVmOpt(b, "tests.multiplier", RANDOM_MULTIPLIER);
            }
            if (TEST_NIGHTLY)
            {
                AddVmOpt(b, SYSPROP_NIGHTLY, TEST_NIGHTLY);
            }
            if (TEST_WEEKLY)
            {
                AddVmOpt(b, SYSPROP_WEEKLY, TEST_WEEKLY);
            }
            if (TEST_SLOW)
            {
                AddVmOpt(b, SYSPROP_SLOW, TEST_SLOW);
            }
            if (TEST_AWAITSFIX)
            {
                AddVmOpt(b, SYSPROP_AWAITSFIX, TEST_AWAITSFIX);
            }

            // Codec, postings, directories.
            if (!TEST_CODEC.Equals("random"))
            {
                AddVmOpt(b, "tests.codec", TEST_CODEC);
            }
            if (!TEST_POSTINGSFORMAT.Equals("random"))
            {
                AddVmOpt(b, "tests.postingsformat", TEST_POSTINGSFORMAT);
            }
            if (!TEST_DOCVALUESFORMAT.Equals("random"))
            {
                AddVmOpt(b, "tests.docvaluesformat", TEST_DOCVALUESFORMAT);
            }
            if (!TEST_DIRECTORY.Equals("random"))
            {
                AddVmOpt(b, "tests.directory", TEST_DIRECTORY);
            }

            // Environment.
            if (!TEST_LINE_DOCS_FILE.Equals(DEFAULT_LINE_DOCS_FILE))
            {
                AddVmOpt(b, "tests.linedocsfile", TEST_LINE_DOCS_FILE);
            }
            if (classEnvRule != null)
            {
                AddVmOpt(b, "tests.locale", classEnvRule.locale);
                if (classEnvRule.timeZone != null)
                {
                    AddVmOpt(b, "tests.timezone", classEnvRule.timeZone.ID);
                }
            }

            AddVmOpt(b, "tests.file.encoding", System.getProperty("file.encoding"));

            Console.Error.WriteLine(b.ToString());
        }