geberit / Revit.TestRunner

Unit Test Runner for Autodesk Revit
MIT License
84 stars 30 forks source link

OneTimeSetUp does not work #12

Closed michastei closed 3 years ago

michastei commented 3 years ago

I want implement unit tests for my Revit plugins. I wrote some basic tests according to the SampleTestProject2 in the repo. Further I tried to implement a OneTimeSetUp, to load a revit project and then execute some tests using this revit project. Unfortunately the OneTimeSetup is never executed. To reproduce, I added

[OneTimeSetUp]
        public void init()
        {
            MessageBox.Show("OnetimeSetup wokrs!");
        }

to the RevitTest-Class. But nothing happens.

If i change the lines to

[SetUp]
        public void init()
        {
            MessageBox.Show("Setup wokrs!");
        }

the message box displays two times as expected. But i want the Setup only apply once.

Further I made a Testproject using only Nunit without Revit. There, the OneTimeSetUp works.

Can you help me according this topic? Michael

tobiasfloescher-geberit commented 3 years ago

Hi Michael According to the documentation (readme.md) only SetUp and TearDown attribute are supported. Since all tests run individually, they are not grouped by class, not possible to call a OneTime method at the right time. I will keep that in mind for a future release. Tobias

tobiasfloescher-geberit commented 3 years ago

Hi Michael. Now OnTimeSetup and OneTimeTearDown are supported. Please have a try.

michastei commented 2 years ago

Hi Tobias, thank you for the implementation. I am sorry for my late reply! I had a try:

[OneTimeSetUp]
        public void Init(UIApplication uiApp)
        {
            UIDocument uiDoc = uiApp.OpenAndActivateDocument("PATH/GOES/HERE");
        }

        [Test]
        public void PassTest()
        {
            Assert.True(true);
        }

        [Test]
        public void FailTest()
        {
            Assert.True(false, "This Test should fail!");
        }

But the project is not loaded BEFORE the tests. It loads during the same time and the tests will be some kind of ignored. They are not marked red or green afterwards. Do I handle the OneTimeSetup correctly? Best Regards Michael