Snippets. How to make the process of working with documentation easier


Hello, Habr! My name is Pavel Lesyuk. I am a tester of native mobile applications. In my previous article, I gave a list of tools that testers and some other experts can use to increase the productivity of their work.

In a new series of articles, I would like to take a closer look at some tools and illustrate their use with examples. The first article will be devoted to the most effective and simplest solution - snippets.

Snippets - are fragments of the text (code), which is stored for later reuse. Snippets come in three forms: static (plain text), dynamic (using variables), and scripting (using code).

In this article, we will look at examples of creating static and dynamic snippets when working with desktop and mobile applications. Remember that snippets are a universal tool that can be used by any specialist working with textual information.

Desktop Tools


We will consider the entire process using the TextExpander program for macOS as an example . There are versions for Windows, Chrome, iOS. This is the most functional tool. Cost: $ 4.16 per month or $ 3.33 per month for an annual subscription. As an alternative, I would advise trying PhraseExpress . There are versions for macOS, Windows, iOS, Android.

MacOS has built-in auto-replace. You can find it along the path: “Settings” → “Keyboard” → “Text”.


It only supports plain text, so it can only be used for simple templates.

Filling out defect reports


Let's say we want to automate the process of creating defect reports. First, create the most complete template for filling out the description in the Jira bug tracking system. We will take into account the fact that in the future we will want to create all combinations of the most frequently used fields to fill out the description of reports. Let's get started.

Creating a snippet group


First, create a group of snippets and give it a name.

Assigning a name and abbreviation


Now you need to create a new snippet, give it a name and abbreviation. Name - identifier with which you can quickly determine what is contained in the snippet and find it if necessary. Abbreviation - a sequence of characters, upon entering which the contents of the snippet will be inserted.

Here are a few properties of good acronyms:

  1. . , ( ). «report», . , , . , . , «,report» . — .
  2. . . , . , «,bg», «,bg2», «2» .
  3. . , . , «Bug report» «,report» «,bg».
  4. . .

In most cases, I prefer to use names and abbreviations in English. We will call the first snippet “Environment, preconditions, steps, actual and expected result” (remember, we will want to create some more combinations of these parameters, so I think this name is the most suitable). The abbreviation is “, epsae”, which corresponds to the first letters of the words in the name. You can also configure case sensitivity.

Snippet Fill


Fill the snippet with content to describe the report.

We have created a static snippet. The characters “*” and “#” are the formatting syntax in Jira (bold and numbered list, respectively). Let's see how the insert works.


Much better than entering all this manually or looking for the desired template in notes, isn't it? In the settings you can set the snippet insertion options. Insertion can occur immediately after input or after pressing the limit key.

In the same way, we can create templates for all used combinations of fields in the description of the defect report. You can create exactly the set of templates that we will use most often.

For example, I have this set as follows:

  • Preconditions, steps, actual and expected result
  • Preconditions, actual and expected result
  • Steps, actual and expected result
  • Actual and expected result

Using dynamic elements


Let's look at a few more examples.

For example, I need to quickly embed a link in the text when preparing a report. When using the built-in tool in Jira, it looks like this:


It seems not bad, we can immediately start typing. But what if, instead of example.com, I want to paste the already copied link from the clipboard? To do this, we need the ability to create dynamic content inside the snippet.

Using dynamic elements, we paste the content copied to the clipboard and place the cursor at the position we need. Let's see how the insert works.


Now we will improve our first template. Suppose you are a mobile tester, you have a fleet of mobile devices, part of which is assigned to you. You are testing on these devices most often, and you would like to have a list of them at hand when preparing a defect report.

First, create a list of devices. We do this using the optional items to select.

Next, create a list of hosts on which we are testing. Add a new snippet to our group and again use the optional elements.

Fine! Now let's move on to our main snippet and enrich it with content. We added the insertion of optional elements from other snippets and set the cursor position so that you can immediately start entering text. Let's see how our advanced snippet works.




When inserting dynamic elements that expect some actions from the user (filling, selection, etc.), a separate window will open in which the corresponding actions will need to be performed on these elements.

Creating note templates


Another example: creating templates for the structure of work notes. I keep notes with markdown support for builds of mobile apps with a specific structure and use snippets to generate them quickly. Below is an example of inserting a finished template into notes.




Filling out test forms


When working with web / desktop applications, you can use snippets to fill out forms with data.

By simulating pressing the Tab button, the transition between fields occurs automatically.


Reporting


Consider creating a test report. Suppose that once a week we write a report on new projects in mobile applications.

We use dynamic elements, formatted text and pictures.

As a result, we get a ready-made report structure, which can be quickly filled with the necessary values ​​and send a letter.


Mobile OS Tools


Android


On Android, you can use Texpand or Gboard . Unfortunately, in both applications there is no synchronization between devices.

Gboard only supports plain text. In fact, this is an extended clipboard in which you can pin some of the fragments.


In Texpand opportunity wider. The free version has support for 10 snippets, dynamic dates and times, pasting from the clipboard and setting the cursor position. You can also backup and import snippets to other devices.


iOS


IOS has a built-in auto-replace, supports only plain text.

There are also versions of TextExpander and PhraseExpress for iOS.

In TextExpander, all snippets are synchronized between the desktop and mobile versions. There are a number of limitations in the mobile version compared to the desktop version:

  1. Snippets are opened when printing only when the TextExpander keyboard is active (the keyboard comes with the application, which can be enabled in the iOS settings).
  2. Interaction with dynamic elements (filling, selection, etc.) works only in the application itself, in the "Notes" segment. From there, the completed snippet can be copied or sent through the sharing menu.
  3. Script snippets do not work (they were not considered in this article).


You can add snippets to your favorites for quick access from the keyboard.

Below is an example of working with a dynamic snippet.


Conclusion


We examined the work of static and dynamic snippets using the example of creating test documentation. They can also be used to create various kinds of letters (repeated mailing lists, job offers, etc.), the structure of documents and notes, code generation, and much more .

Thank you for reading the article to the end. I hope the information contained in it will be useful to you, and you can save time by using it in practice. If you have any questions about the article - I will be glad to answer them. In the next article, I plan to write about using script snippets. In the meantime, I propose to subscribe to my Telegram channel , where I publish all other information on the topic of testing.

Source: https://habr.com/ru/post/undefined/


All Articles