Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to implement custom Nunit Attribute on a [UnityTest] Test Framework 1.3.0

Discussion in 'Testing & Automation' started by daicoden, Nov 4, 2022.

  1. daicoden

    daicoden

    Joined:
    Mar 21, 2022
    Posts:
    6
    Hi,

    How are you supposed to write a test attirbute for a test marked with UnityTest On the test framework 1.3.0?

    The TestCommandBuilder has the following:

    Code (CSharp):
    1.                
    2.                 if (testReturnsIEnumerator && !(command is IEnumerableTestMethodCommand))
    3.                 {
    4.                     command = TryReplaceWithEnumerableCommand(command);
    5.                     if (command != null)
    6.                     {
    7.                         continue;
    8.                     }
    9.                    
    10.                     var message = String.Format("'{0}' is not supported on {1} as it does not handle returning IEnumerator.",
    11.                         wrapper.GetType().FullName,
    12.                         GetTestBuilderName(test));
    13.                     return new FailCommand(test, ResultState.Failure, message);
    14.                 }

    IEnumerableTestMethodCommand is marked internal, so you can't extend it. TryReplaceWihtEnumerable hardcodes a couple of known classes.

    I can get my enumerable test method attribute to work if I mark IEnumerableTestMethodCommand as public... is there a way to make internals for the testing framework visible to an assembly... or something??
     
  2. daicoden

    daicoden

    Joined:
    Mar 21, 2022
    Posts:
    6
    aha - IOuterUnityTestAction let's you do something - Would still be nice if IEnumerableTestMethodCommand was public to get access to the context and such.
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,082
    There's a dedicated forum for Test Automation here. I'll move your post for you.