Skip to content

Commit 25e58e0

Browse files
committed
add plant uml generator performance test
1 parent 0ad87fa commit 25e58e0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { afterEach, beforeAll, describe, expect, test } from 'vitest'
2+
import path from 'node:path'
3+
import fs from 'node:fs'
4+
import { createContextMapperDslServices } from '../../src/language/ContextMapperDslModule.js'
5+
import { NodeFileSystem } from 'langium/node'
6+
import { clearDocuments } from 'langium/test'
7+
import { ExecuteCommandHandler } from 'langium/lsp'
8+
9+
const outDir = path.join(__dirname, 'out')
10+
11+
let services: ReturnType<typeof createContextMapperDslServices>
12+
let commandHandler: ExecuteCommandHandler
13+
14+
beforeAll(() => {
15+
services = createContextMapperDslServices(NodeFileSystem)
16+
commandHandler = services.shared.lsp.ExecuteCommandHandler!
17+
})
18+
19+
afterEach(async () => {
20+
await clearDocuments(services.shared, services.shared.workspace.LangiumDocuments.all.toArray())
21+
fs.rmSync(outDir, {
22+
recursive: true,
23+
force: true
24+
})
25+
})
26+
27+
describe('PlantUML component diagram generation - performance test', () => {
28+
test('test PlantUML generation performance for stage 3 DDD-Sample', async () => {
29+
const file = path.join(__dirname, '..', 'example-files', 'DDD-Sample-Stage-3.cml')
30+
31+
const startTime = Date.now()
32+
const result = await commandHandler.executeCommand('org.contextmapper.GeneratePlantUML', [file, outDir])
33+
const endTime = Date.now()
34+
35+
expect(result).toHaveLength(1)
36+
const outContent = fs.readdirSync(outDir)
37+
expect(outContent).toHaveLength(1)
38+
expect(endTime - startTime).toBeLessThanOrEqual(500)
39+
})
40+
})

0 commit comments

Comments
 (0)