Interface NCTestClient


  • public interface NCTestClient
    Model testing client. This client can be used for convenient unit testing of the models together with any popular unit testing framework such as TestNG or JUnit. The instance of test client should be obtained via NCTestClientBuilder.

    Here's an code snippet from Alarm Clock example illustrating the usage of test framework together with JUnit 5:

     public class AlarmTest {
         private NCTestClient cli;
    
         @BeforeEach
         void setUp() throws NCException, IOException {
             NCEmbeddedProbe.start(AlarmModel.class);
    
             cli = new NCTestClientBuilder().newBuilder().build();
    
             cli.open("nlpcraft.alarm.ex");
         }
    
         @AfterEach
         void tearDown() throws NCException, IOException {
             if (cli != null)
                 cli.close();
    
             NCEmbeddedProbe.stop();
         }
    
         @Test
         public void test() throws NCException, IOException {
             // Should be passed.
             assertTrue(cli.ask("Ping me in 3 minutes").isOk());
             assertTrue(cli.ask("Buzz me in an hour and 15mins").isOk());
             assertTrue(cli.ask("Set my alarm for 30s").isOk());
         }
     }
     
    See Also:
    NCTestClientBuilder