Path: blob/main/extensions/copilot/test/simulation/slash-test/testGen.java.stest.ts
13394 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as assert from 'assert';6import * as path from 'path';7import { Intent } from '../../../src/extension/common/constants';8import { URI } from '../../../src/util/vs/base/common/uri';9import { ssuite, stest } from '../../base/stest';10import { forInline, simulateInlineChatWithStrategy } from '../inlineChatSimulator';11import { getFileContent } from '../outcomeValidators';12import { assertWorkspaceEdit, fromFixture } from '../stestUtil';131415forInline((strategy, nonExtensionConfigurations, suffix) => {1617ssuite({ title: `/tests${suffix}`, location: 'inline', language: 'java', nonExtensionConfigurations }, () => {1819stest({ description: 'looks up pom.xml and junit framework info', }, (testingServiceCollection) => {20return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {21workspaceFolders: [22URI.file(path.join(__dirname, '../test/simulation/fixtures/tests/java-example-project'))23],24files: [25fromFixture('tests/java-example-project', 'src/main/java/com/example/MyCalculator.java'),26],27queries: [{28file: 'src/main/java/com/example/MyCalculator.java',29selection: [4, 15],30query: '/tests',31expectedIntent: Intent.Tests,32validate: async (outcome, workspace, accessor) => {33assertWorkspaceEdit(outcome);34assert.strictEqual(outcome.files.length, 1, 'Expected one file to be created');35assert.ok(36getFileContent(outcome.files[0]).includes('import org.junit.jupiter.api.Test;') || // JUnit 5 -- TODO@ulugbekna: we can't yet parse versions of test frameworks37getFileContent(outcome.files[0]).includes('import org.junit.Test;') // JUnit 438);39}40}],41});42});4344stest({ description: 'looks up existing test file', nonExtensionConfigurations }, (testingServiceCollection) => {45return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {46workspaceFolders: [47URI.file(path.join(__dirname, '../test/simulation/fixtures/tests/java-example-project-with-existing-test-file'))48],49files: [50fromFixture('tests/java-example-project-with-existing-test-file', 'src/main/java/com/example/MyCalculator.java'),51],52queries: [{53file: 'src/main/java/com/example/MyCalculator.java',54selection: [4, 15],55query: '/tests',56expectedIntent: Intent.Tests,57validate: async (outcome, workspace, accessor) => {58assertWorkspaceEdit(outcome);59assert.strictEqual(outcome.files.length, 1, 'Expected one file to be created');60assert.ok(61getFileContent(outcome.files[0]).includes('test #2')62);63}64}],65});66});6768});6970});717273