Workflow for autonomous testing of 1C business logic:
- AI creates test data via
1c-ai-debugMCP (CRUD) - AI writes a test — a CommonModule with the suffix
_Test - The test is loaded into the database via
/db-load-xml+/db-update - AI runs it via the MCP tool
run_unit_tests - The result is returned as text/JSON — no screenshots, no vanessa-runner
Prerequisites
1c-ai-debugMCP is connected to the project- The AI_Debug extension is installed and published in the database
Stack
Claude → 1c-ai-debug MCP (run_unit_tests) → 1С база
↑
BSL: CommonModule *_Test (пишет Claude)
↑
CRUD: create_catalog_item, create_document, post_document
Step 1 — Create test data
{"name": "create_catalog_item", "arguments": {"catalogName": "Контрагенты", "data": {"Наименование": "TEST-001"}}}
{"name": "create_document", "arguments": {
"documentType": "ПоступлениеТоваровУслуг",
"header": {"Контрагент": "<ref>", "Дата": "2026-01-01T00:00:00"},
"tables": {"Товары": [{"Номенклатура": "<ref>", "Количество": 10, "Цена": 100}]}
}}
{"name": "post_document", "arguments": {"documentType": "ПоступлениеТоваровУслуг", "documentRef": "<ref>"}}
Step 2 — Write a test
Test — a CommonModule with the suffix _Test. Example of the module AI_SelfTest_Test already included in AI_Debug.
// CommonModules/ТестПроведенияПоступления_Test/Ext/Module.bsl
#Область СлужебныйПрограммныйИнтерфейс
Процедура ИсполняемыеСценарии() Экспорт
ЮТТесты.ДобавитьТест("ПроведениеПоступленияФормируетДвижения");
КонецПроцедуры
Процедура ПроведениеПоступленияФормируетДвижения() Экспорт
// Arrange — ссылка из шага 1
ДокументСсылка = ПредопределённоеЗначение("..."); // или передать через параметры
// Act + Assert
Движения = РегистрыНакопления.ТоварыНаСкладах.СоздатьНаборЗаписей();
Движения.Отбор.Регистратор.Установить(ДокументСсылка);
Движения.Прочитать();
ЮТУтверждения.Больше(Движения.Количество(), 0, "Ожидаются движения по регистру");
КонецПроцедуры
#КонецОбласти
YUTAssertions API (direct calls)
ЮТУтверждения.Равно(Факт, Ожидаемое, "комментарий")
ЮТУтверждения.НеРавно(Факт, НеОжидаемое)
ЮТУтверждения.ЭтоИстина(Условие, "комментарий")
ЮТУтверждения.ЭтоЛожь(Условие)
ЮТУтверждения.Больше(Значение, Порог, "комментарий")
ЮТУтверждения.Меньше(Значение, Порог)
ЮТУтверждения.НеЗаполнено(Значение)
ЮТУтверждения.Заполнено(Значение)
ЮТУтверждения.ИмеетДлину(Коллекция, N)
⚠️ Fluent style (
ЮТУтверждения.Что(X).Равно(Y)) does not work in a CommonModule — there is no self-reference.
Add the test to the configuration
<!-- Configuration.xml → ChildObjects -->
<CommonModule>ТестПроведенияПоступления_Test</CommonModule>
CommonModule flags: Server=true, ClientManagedApplication=false.
Step 3 — Load into the database
/db-load-xml <configDir> -Mode Partial -Files "CommonModules/ТестПроведенияПоступления_Test.xml,CommonModules/ТестПроведенияПоступления_Test/Ext/Module.bsl"
/db-update
Step 4 — Run the tests
// Все _Test модули
{"name": "run_unit_tests", "arguments": {}}
// Конкретный модуль
{"name": "run_unit_tests", "arguments": {"moduleName": "ТестПроведенияПоступления_Test"}}
Result format
{
"success": true,
"total": 3,
"passed": 3,
"failed": 0,
"summary": "[OK] ПроведениеПоступленияФормируетДвижения\n[OK] ..."
}
When failed > 0 — success: false, в summary lines [FAIL] ИмяТеста: текст ошибки.
Step 5 — Cleanup
{"name": "delete_object", "arguments": {"objectType": "Documents", "objectName": "ПоступлениеТоваровУслуг", "objectRef": "<ref>"}}
{"name": "delete_object", "arguments": {"objectType": "Catalogs", "objectName": "Контрагенты", "objectRef": "<ref>"}}
Complete example (end-to-end)
1. create_catalog_item(Номенклатура, {Наименование: "TEST-001"}) → ref_ном
2. create_document(ПоступлениеТоваровУслуг, {Товары: [{Номенклатура: ref_ном, Кол: 5, Цена: 200}]}) → ref_doc
3. post_document(ПоступлениеТоваровУслуг, ref_doc) → success: true
4. Claude пишет BSL тест → /db-load-xml + /db-update
5. run_unit_tests({moduleName: "ТестПроведенияПоступления_Test"}) → {success: true, passed: 1}
6. delete_object x2 (cleanup)
Limitations
- Tests cover only server business logic: calculations, movements, posting — not UI
- The test is loaded into the database before running via
/db-load-xml+/db-update - References between objects — GUID strings from create_* responses
post_documentrequiresРежимЗаписиДокумента.Проведение— the database must allow posting
Related skills
/db-load-xml— load the test module into the database/db-update— apply to the DB1c-ai-debugMCP — data CRUD and runningrun_unit_tests