Automated testing suggestions

224 views
Skip to first unread message

Eric Edem

unread,
Dec 2, 2020, 4:35:36 PM12/2/20
to Blockly
Hey all,

I'm getting ready to deploy my application, and one of the things I'm not sure about is how to handle automated testing. I'm wondering if anyone has any recommendations on how to test an enterprise production ready application with blockly?

Has anyone successfully used tools like Cypress (end to end testing) or React Testing Library (Unit) to test dom changes and validate output?

I've validated that I can use React Testing Library to render the DOM and generate code / XML, but I'm not sure about testing interactions. Is there a way to apply attributes to interactive elements so that we can select them? Is there a good way to handle the dragging behaviors in blockly?

Sorry for this rambling question, thanks in advance for all your ideas :)

-Eric

Beka Westberg

unread,
Dec 3, 2020, 4:43:23 PM12/3/20
to blo...@googlegroups.com
Hi Eric,

It's really cool that you want to add unit tests! But I would recommend going about it in a slightly different manner.

When testing the integration of a 3rd party library (such as Blockly) a good strategy is to treat the library as a black box. So any time you talk to it, you want to make sure that you get the right reply back. But anytime it talks to itself (eg handling block dragging) you don't care. That stuff is the core Blockly team's problem.

I would recommend focusing on testing things that you've added to Blockly. Eg any block code generators, dynamic dropdowns, or dynamic categories that you've added. These can all be run in headless mode, and easily mocked :D

The Blockly team uses mocha for testing, and primarily runs things in headless mode (meaning without DOM). You can see all of the current unit tests here. There are also tests in some of the blockly-samples directories (eg strict-connection-checker, workspace-search) which use ES6 language features.

I hope that gives you some place to start! Other people may have different opinions or more info as well =)
--Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/993d98dd-bca2-41d5-a836-dc815a74db71n%40googlegroups.com.

Eric Edem

unread,
Dec 3, 2020, 5:01:16 PM12/3/20
to blo...@googlegroups.com
Gotcha, if I understand correctly, the recommendation is not to try to do interaction testing. I think this is actually pretty reasonable given that Blockly itself is well tested.

One thing I'm currently attempting in my tests right now to get more of an end to end experience is the following:

1. Create a blocky XML with my custom blocks
2. Call my code generator to generate code from the custom blocks (Lua in our case)
3. Run the generated code through the Lua interpreter with some stubbed methods that output the calls
4. Validate that the output was what we expected.

I originally spent some time trying to validate generator output with snapshots, but small changes would result in all the snapshot tests breaking, so I'm hoping that this scheme will prove a little more robust.

An added benefit to this method laid out above is that it should be pretty reasonable for more long-term regression testing, in addition to making sure that generated code results in a syntactically correct program :D.

Best,
Eric

You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/y2DE3YGlaT8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/CAEBzR96JkHU-%2BGnM_d%3D9%3DHS6m4uwVwUqptwO6QXUwUquKEE5QQ%40mail.gmail.com.

sujeith gopinath

unread,
Jan 31, 2023, 5:06:55 AM1/31/23
to Blockly
Hi, 

So were you able to do the interaction testing?

Reply all
Reply to author
Forward
0 new messages