Best practices for testing a conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bleese
Posts: 7
Joined: Tue Apr 05, 2022 9:29 am

Best practices for testing a conversation

Post by bleese »

Hi! Before I get started writing my own testing pipeline, I was wondering if there are best practices for testing a conversation. I want to test every conversation node and I want to try and avoid just running the conversation a hundred times (I have very complex conversations, some with over 1,000 nodes each connected in elaborate ways).

The class of errors I want to test for are as follows:

1. Does the LUA sequencer, condition and script compile (no syntax errors) (Note I have C# calls in these Lua scripts).
2. Are there unintended ending nodes (IE: A node that ends the conversation when it really shouldn't)
3. Are there spelling errors in the text of the node.
4. Are there conditions where no response nodes would be displayed (For example: Suppose a node has two child nodes, one with condition Foo > 0 and one with condition Foo < 0, in this case Foo = 0 would result in an unintended ending node).

I am ok with each class of errors having their own testing method and I'm ok with the testing method being somewhat manual. I do want to test EVERY single node though with this method.

My current idea is to create a hook into the dialogue system that forces the dialogue system to render every dialogue node, in order, by entryID (this satisfies condition 1 and 3), then it should print out the children node (if any) and their conditions (which could satisfy condition 2 and 4). But if there's a better more supported way for some of these, I'd be happy to hear it!
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best practices for testing a conversation

Post by Tony Li »

Hi,

> 1. Does the LUA sequencer, condition and script compile (no syntax errors) (Note I have C# calls in these Lua scripts).

For sequences, create a SequenceParser and use SequenceParser.Parse():

Code: Select all

var sequenceParser = new SequenceParser();
sequenceParser.Parse(sequence);
Syntax errors will log a warning to the Console. In version 2.2.33, SequenceParser.Parse() has an option to throw exceptions. If you'd like an advance copy, let me know.

For Lua, register stub C# methods for the Lua functions if you don't want to run the actual C# methods. Then run them through Lua.Run().

Code: Select all

Lua.Run(dialogueEntry.conditionsString);
Lua.Run(dialogueEntry.userScript);
If there's a syntax error, they'll throw an exception.


> 2. Are there unintended ending nodes (IE: A node that ends the conversation when it really shouldn't)

I'm not sure what kind of checks you want for this, but to identify an ending node you can check if the dialogue entry's outgoingLinks list is empty. This won't catch links that lead to nodes with conditions that are always false.


> 3. Are there spelling errors in the text of the node.

If you want to do this in Unity, you can loop through all conversations and dialogue entries and run the DialogueText and MenuText fields through your own spell checker.

Otherwise you can export to CSV using Localization Export/Import, open them in Excel or Google Sheets, and run spell check there.


> 4. Are there conditions where no response nodes would be displayed (For example: Suppose a node has two child nodes, one with condition Foo > 0 and one with condition Foo < 0, in this case Foo = 0 would result in an unintended ending node).

That's a tough one to fully automate. Your approach might be best -- if a node links to other nodes with conditions, print a report that shows the conditions so you can visually check that they cover all cases.
bleese
Posts: 7
Joined: Tue Apr 05, 2022 9:29 am

Re: Best practices for testing a conversation

Post by bleese »

Alright thank you, that sounds awesome, I'll get on that!

One thing, is there way in the Dialogue Conversation Editor window to highlight nodes that have no child nodes (similar to how orphaned nodes show up as red in the dialogue window). I think that would solve 2, because currently my dialogue tree might be a big mess of nodes and it's hard to see if inside that mess there are nodes that aren't actually connected to child nodes.

If not, yeah your second approach might be fine (and satisfies the first approach as well).
bleese
Posts: 7
Joined: Tue Apr 05, 2022 9:29 am

Re: Best practices for testing a conversation

Post by bleese »

So I've written the above methods and it works well, I know have a CSV of errors and info logs (And I edited the Sequencer Parse code myself to return exceptions), all looks good.

Only issue I'm having now is fixing the errors. In my log I get the entry node ID (and subtitle text) that has the error, as well as the error that's returned. My issue is, in the Dialogue Editor, how can I find that node? It's a little hard to find node "253", it would be convenient if there was a way to select node by entry ID in the dialogue editor.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best practices for testing a conversation

Post by Tony Li »

Hi,

> is there way in the Dialogue Conversation Editor window to highlight nodes that have no child nodes

Currently nodes with no outgoing links have a red triangle beneath them. If you want to draw them differently, you could assign a custom method to DialogueEditorWindow.customDrawDialogueEntryNode (more info - customizing editor)


> My issue is, in the Dialogue Editor, how can I find that node? It's a little hard to find node "253", it would be convenient if there was a way to select node by entry ID in the dialogue editor.

Call DialogueEditorWindow.OpenDialogueEntry().
bleese
Posts: 7
Joined: Tue Apr 05, 2022 9:29 am

Re: Best practices for testing a conversation

Post by bleese »

Ok, really dumb question, I'm sorry for asking so many questions but you've been incredibly helpful through this process!

I can't seem to import PixelCrushers.DialogueSystem.DialogueEditor. I tried to import DialogueSystemAssemblyDefinitions.unitypackage per the FAQ but that caused TMPro import to fail (as expected via the FAQ) but funnily enough not in MY assembly but in the DialogueSystem assembly (So I could use TMPro in my scripts, but the DialogueSystem scripts were failing). After trying to debug it for too long I was forced to rollback to a previous version (I don't know where the TMPro assembly definition exists in my project folders ever since TMPro is now packaged by default).

So I'm forced to limp back with my tail between my legs haha, how would I add the assembly reference I need for PixelCrushers.DialogueSystem.DialogueEditor.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best practices for testing a conversation

Post by Tony Li »

Hi,

Since you're using TMPro and Dialogue System asmdefs, you'll want to assign the Unity.TextMeshPro asmdef to these asmdefs if you haven't already:

PixelCrushers
PixelCrushersEditor
DialogueSystem
DialogueSystemEditor

If you've tried that already and it hasn't fixed the issue, where is your code located? Is it in the Plugins folder? (Outside Plugins is probably best.) Does your code use an asmdef, too?
Post Reply