Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

unit test: what is interactive session, and how to confirm that the test case is running on interactive session or batch?

Posted on by

Description:

 i don't understand what is interactive session, i cannot find any documents about it.

and i have a test class, and there is a test case in it. the test case will open a form though formAdaptor , and i need to judgment whether it running on interactive session. 

i know that we can use isRunningBatch() and hasGUI() to check it. but i don't understand why it is running on batch or why it is running on interactive session? how are these judged?

the following code you can have a reference, i am a little confused what is the basis of judgmet?

if you know, please give me some suggestions, thanks!

For example:

using System;
using System.Globalization;
class TestClass extends SysTestCase
{

    [SysTestMethod]
    public void tsetMethod1()
    {
        boolean beforeBatch = isRunningOnBatch();
        boolean beforeinterative = hasGUI();

        container beforeResult = [beforeBatch, beforeinterative];

        // Arrange
        using (var formAdaptor = BatchJobHistoryFormAdaptor::open())
        {
            // simulate running in interactive session
            
            boolean isBatch = isRunningOnBatch();
            boolean isinterative = hasGUI();
            container result = [isBatch, isinterative];

            // Assert
            this.assertEquals([false /*isbatch*/, true /*isInteractive*/], result, ' did not match the expected.');
        }
    }

    [SysTestMethod]
    public void testMethod2()
    {
        boolean beforeBatch = isRunningOnBatch();
        boolean beforeinterative = hasGUI();

        container beforeResult = [beforeBatch, beforeinterative];

        using (var batchHandler = new SysTestBatchExecutionWrapper())
        {
            boolean isBatch = isRunningOnBatch();
            boolean isinterative = hasGUI();
            container result = [isBatch, isinterative];

            // Assert
            this.assertEquals([true /*isbatch*/, false /*isInteractive*/], result, ' did not match the expected.');
        }
    }


}

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,336 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans