0
I am having a problem using abstract classes to keep the common code of my tests, shutdown boot etc... I use a concrete class only to initialize the variables. The code inherited from the abstract class does not run when running the tests, I believe it is some configuration missing, follow an example code:
namespace meusTestes
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
public abstract class AbTest
{
public abstract string getString();
[Test]
public void SharedTest()
{
Assert.NotNull(getString()); //Don't execute
}
}
[TestFixture]
public class RealTest : AbTest
{
public override string getString()
{
return " "; //Don't execute
}
[Test]
public void InternalTest()
{
Assert.IsTrue(true); // Execute
}
}
}
The Internaltest runs correctly, but the inherited test (Sharedtest) of the abstract class does not, my doubt is why the inherited test does not run.
"O código da classe abstrata não é executado (...)"
From what you posted, she doesn’t even have code that can be executed.– Oralista de Sistemas
In the Nunit documentation it is possible to inherit the tests, it follows: May not be Abstract - Although the attribute may be Applied to an Abstract class intended to serve as a base class for test fixtures. http://www.nunit.org/index.php?p=testFixture&r=2.5.9
– CleversonMachado
I’m not sure what it might be, but have you tried writing an empty override? Something like:
public override void SharedTest() : base() { }
– Leonel Sanches da Silva
Well around, I’ll post the answer, thanks Gypsy
– CleversonMachado