xUnitFor1C Documentation

repository·develop·Indexed 18 days ago

https://github.com/xdrivendevelopment/xunitfor1c

A comprehensive testing framework for the 1C:Enterprise 8 platform (versions 8.2.17 to 8.3.6 and higher). It enables unit, integration, acceptance, and scenario testing across Standard, Thin, and Thick client modes. The suite includes xddTestRunner.epf for test execution, support for automated command-line runs for CI/CD integration, and specialized smoke tests for verifying metadata object forms and document creation logic.

Tokens
3.7K
Snippets
5
Records
18
Agent score
13%

What's inside xUnitFor1C

  1. Overview of Smoke Tests in xUnitFor1C

    develop

    xUnitFor1C provides a universal implementation of smoke tests designed for 1C:Enterprise 8. These tests allow you to perform basic checks without writing complex test code or modifying the 1C configuration development schema.

    Smoke tests are recommended to be run:

    1. Before releasing or updating a configuration.
    2. Before installing a release or update into a production database.
  2. Overview of xUnitFor1C

    develop
    xUnitFor1C is a testing framework designed for the 1C:Enterprise 8 platform. It provides tools for various testing types, including unit, acceptance, scenario (for 1C 8.3), and integration testing. The framework is designed to be independent of any specific configuration, though it can be embedded within one. It supports multiple client modes (Standard, Thin, and Thick clients) and is compatible with 1C platforms ranging from 8.2.17 to 8.3.6 and higher.
  3. What are Smoke Tests in xUnitFor1C

    develop

    Smoke tests in xUnitFor1C are automated tests that verify the opening and closing of various metadata object forms (Catalogs, Documents, Reports, and Processing tools) while accounting for user access rights (Usage/View permissions).

    Key coverage includes:

    • Catalogs (Справочники): List forms, selection forms, and element forms. Includes additional tests for creating new elements, copying existing elements, and opening existing elements.
    • Documents (Документы): List forms, selection forms, and document forms. Includes tests for opening existing documents (by date), transferring documents to the current date, and opening new documents.
    • Reports (Отчеты) and Processing (Обработки): Form opening/closing.

    These tests are designed to ensure that the most critical UI components of a 1C:Enterprise configuration are functional and accessible to users with different roles.

  4. Generate test data from layouts

    develop
    The framework allows for easy creation of test data using tabular layouts (макеты). These layouts can be generated from real production data. Once created, the data can be loaded into tests using a single line of code, simplifying the setup of complex test scenarios.
  5. Available types of Smoke Tests

    develop

    Currently, xUnitFor1C supports two types of smoke tests, each implemented as a separate processing tool (обработка):

    1. Metadata Object Form Open/Close Smoke Tests: Tests the ability to open and close forms for various metadata objects.
    2. Document Creation Based on Other Documents Smoke Tests: Tests the logic of creating documents based on existing ones.
  6. Run tests automatically via command line

    develop
    xUnitFor1C supports fully automated test execution through a specialized command line interface. This allows for integration into Continuous Integration (CI) systems and build servers (such as Jenkins or TeamCity). Tests can be implemented as either external processing files or embedded within the configuration.
  7. Components of xUnitFor1C

    develop

    The xUnitFor1C toolset consists of the following main components:

    • xddTestRunner.epf: The core test runner and browser. It is designed to execute tests for both Ordinary (Thick Client) and Managed (Thin Client) 1C:Enterprise 8 applications.
    • Tests/: A directory containing test examples and self-tests used to verify the functionality of xddTestRunner.epf (located in the selftests subfolder).

    Specific test examples provided in the repository include:

    • Form Opening Tests: Tests\CommonApp\тесты_ОткрытиеФормКонфигурации.epf tests the opening of all forms for Catalogs, Documents, Reports, and Data Processors. For Catalogs and Documents, it creates, copies, or overwrites elements within a transaction.
    • Permission/Session Tests: Tests\CommonApp\Тест_ЗапускТестовВСеансеДругихПользователей.epf demonstrates running tests for users with limited rights. Users are created on-the-fly from simple templates.
    • Report Comparison Tests: Tests\CommonApp\Тест_ПроверитьОтчетНаСоответствиеЭталону.epf demonstrates how to test a report by comparing its output against an expected template.
  8. Group smoke tests in interactive mode

    develop

    When running tests interactively via xddTestRunner.epf, you can group the thousands of resulting test cases to make debugging easier. Use the СпособГруппировки key in smoke.json.

    Supported grouping methods:

    • ПоВидуМетаданных: Groups by metadata type (e.g., all Catalogs together).
    • ПоВидуОбъекта: Groups by specific object type.
    • ПоКоличеству: Groups by a fixed number of cases. Requires КоличествоВГруппе to be set. Groups are named like Справочники [1..20], Справочники [21..40], etc.
    • НеГруппировать: The default behavior (flat list).
  9. Configure subordinate catalogs and field values for new objects

    develop

    Handle Subordinate Catalogs

    If a subordinate catalog requires an explicit owner (when multiple owners are possible), specify the owner type in the Подчиненные section of the Справочники configuration.

    {
        "smoke": {
            "Справочники": {
                "Подчиненные": {
                    "БанковскиеСчета": "Контрагенты"
                }
            }
        }
    }

    Set default values for new objects (ЗначенияРеквизитовНовых)

    To ensure forms can open when certain mandatory fields are required, you can define default values for attributes of newly created objects.

    • Simple types: Boolean, String, Number, DateTime are passed directly.
    • Reference types (CatalogRef):
      • Enums: Use the name of the enum value as defined in metadata.
      • Catalogs: A new element will be created using the provided string as its name.
    {
        "smoke": {
            "Справочники": {
                "ЗначенияРеквизитовНовых": {
                    "Номенклатура": {
                        "ВестиУчетПоСериям": true,
                        "ВестиУчетПоХарактеристикам": true
                    },
                    "СотрудникиОрганизаций": {
                        "Физлицо": "Тестовое физлицо"
                    }
                }
            }
        }
    }
  10. How to contribute to xUnitFor1C

    develop

    You can support the project in several ways:

    1. Usage and Feedback: If you develop on 1C:Enterprise 8, try using xUnitFor1C for your testing. Report bugs or suggest features using the GitHub issue tracker.
    2. Code Contributions: If you are familiar with the source code, you can pick up one of the open issues to implement.
    3. Writing Articles: If you use xUnitFor1C in practice, consider writing an article about it (e.g., on Infostart).

    For detailed technical instructions on how to contribute to the code, refer to the Contributor Guide.

  11. Configure Smoke Tests using smoke.json

    develop

    For versions 4.1.X.X and higher, smoke tests are configured using a json file. The file must contain a single root object with the key smoke.

    Loading the configuration

    • Interactive mode: Use the "Load settings from file" (Загрузить настройки из файла) command in the "Load tests" (Загрузить тесты) menu. This must be done before loading the smoke tests themselves. If tests are already loaded, you must reload them after loading the settings.
    • Command line: Pass the path to the configuration file using the xddConfig parameter within the /Execute argument.

    Example Command Line Invocation (Batch/CMD)

    @echo off
    
    set XDD_IBaseConn=Srvr="main:2841";Ref="test_ibase";
    set XDD_IBaseUser="Администратор"
    set XDD_IBasePass=""
    
    rem Paths to executable directories
    set XDD_V8Bin=C:\Program Files (x86)\1cv82\8.2.19.130\bin
    set XDD_xUnitDir=W:\xUnitFor1C
    
    "%XDD_V8Bin%\1cv8.exe" ENTERPRISE /IBConnectionString %XDD_IBaseConn% /N %XDD_IBaseUser% /P %XDD_IBasePass% /RunModeOrdinaryApplication /Execute "%XDD_xUnitDir%\bin\xddTestRunner.epf" /C "xddConfig ""W:\\smoke.json"""; xddRun ЗагрузчикФайла ""%XDD_xUnitDir%\bin\Tests\Smoke\тесты_ОткрытиеФормКонфигурации.epf""";
  12. Smoke testing document creation based on existing documents

    develop

    This smoke testing capability allows you to verify the opening and closing of metadata object forms, specifically focusing on document creation based on existing documents. It is designed to test procedures such as ПриСозданииНаСервере (OnCreateAtServer), ПриОткрытии (OnOpen), and ОбработкаЗаполнения (FillingProcessing).

    This tool can be used with both xUnitFor1C and VanessaBehavior.

    Recommendations:

    • Run these tests against a database that already contains populated documents.
    • For the best results, use the generated feature files as snippets for your automation suite.