Annotation Interface SubcircuitTest


@Retention(RUNTIME) public @interface SubcircuitTest
Marks this JUnit test class as testing a subcircuit with the provided .sim file path and subcircuit name.
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The circuit file to open.
    The name of the subcircuit in which to search for pins.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Reset simulation between tests.
    Class<? extends Restrictor>[]
    Validate the subcircuit with these Restrictors before running any tests.
    boolean
    Verify that the test contains a fixed number of input pins.
  • Element Details

    • file

      String file
      The circuit file to open. Usually a relative path.
      Returns:
      the path of a .sim file
      See Also:
    • subcircuit

      String subcircuit
      The name of the subcircuit in which to search for pins. Normalized as described in Subcircuit.fromPath(String,String).
      Returns:
      the name of the subcircuit. Normalized before lookup
      See Also:
    • restrictors

      Class<? extends Restrictor>[] restrictors
      Validate the subcircuit with these Restrictors before running any tests. Useful for checking for banned gates.

      The idiom is to subclass Restrictor inside your test class and then call Restrictor methods as needed inside its validate(), such as Restrictor.whitelistComponents() or Restrictor.blacklistComponents() as follows:

       @DisplayName("Toy ALU")
       @ExtendWith(CircuitSimExtension.class)
       @SubcircuitTest(file="toy-alu.sim", subcircuit="ALU",
                       restrictors={ToyALUTests.BannedGates.class})
       public class ToyALUTests {
           public static class BannedGates extends Restrictor {
               @Override
               public void validate(Subcircuit subcircuit) throws AssertionError {
                   blacklistComponents(subcircuit, "XOR");
               }
           }
      
           // ...
       }
       
      The default is an empty array, so to perform no validation.
      Returns:
      restrictor classes to use to validate the subcircuit
      See Also:
      Default:
      {}
    • resetSimulationBetween

      boolean resetSimulationBetween
      Reset simulation between tests.

      Defaults to false because of possible performance (OOM) issues with this behavior.

      Returns:
      true if the simulation should be reset before each test, false if the simulation should never be reset
      See Also:
      Default:
      false
    • verifyInputPinCount

      boolean verifyInputPinCount
      Verify that the test contains a fixed number of input pins. This fixed number is determined by the number of InputPin variables with an SubcircuitComponent annotation.

      Defaults to true as students frequently use input pins in place of constant pins, leading to undesired behavior.

      Returns:
      true if the number of input pins should be verified false if it should not
      Default:
      true