Skip to content

Commit 885165d

Browse files
committed
Add unit tests for ChatMessage, ConversationHistory, and Copilot components
- Implement ChatMessageTest to validate user and assistant message creation, timestamp handling, and string representation. - Create ConversationHistoryTest to ensure correct message addition, retrieval, filtering by role, and history management. - Introduce CopilotChatPanelTest to verify UI components and interactions within the Copilot chat panel. - Add CopilotChatServiceTest to test connection handling, message sending, and conversation history management. - Implement JMeterXmlParserTest to validate XML extraction and parsing from markdown and raw XML inputs. - Remove outdated CopilotServiceIntegrationTest that made real API calls, focusing on unit tests for better reliability.
1 parent 42d571a commit 885165d

30 files changed

Lines changed: 3382 additions & 1659 deletions

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
cache: maven
23+
24+
- name: Install Copilot SDK
25+
run: |
26+
# Clone and install Copilot SDK (until it's published to Maven Central)
27+
git clone https://github.com/github/copilot-sdk.git /tmp/copilot-sdk
28+
cd /tmp/copilot-sdk/java
29+
mvn install -DskipTests -q
30+
31+
- name: Build with Maven
32+
run: mvn -B clean verify --file pom.xml
33+
34+
- name: Upload artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: jmeter-copilot-plugin
38+
path: target/jmeter-copilot-plugin-*.jar
39+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: 'Release version (e.g., 1.0.0)'
8+
required: true
9+
type: string
10+
developmentVersion:
11+
description: 'Next development version (e.g., 1.0.1-SNAPSHOT)'
12+
required: true
13+
type: string
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: '17'
32+
distribution: 'temurin'
33+
cache: maven
34+
35+
- name: Configure Git
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "github-actions[bot]@users.noreply.github.com"
39+
40+
- name: Install Copilot SDK
41+
run: |
42+
# Clone and install Copilot SDK (until it's published to Maven Central)
43+
git clone https://github.com/github/copilot-sdk.git /tmp/copilot-sdk
44+
cd /tmp/copilot-sdk/java
45+
mvn install -DskipTests -q
46+
47+
- name: Prepare Release
48+
run: |
49+
mvn -B release:prepare \
50+
-DreleaseVersion=${{ inputs.releaseVersion }} \
51+
-DdevelopmentVersion=${{ inputs.developmentVersion }} \
52+
-DtagNameFormat=v@{project.version} \
53+
-DpushChanges=true \
54+
-Darguments="-DskipTests"
55+
56+
- name: Perform Release
57+
run: |
58+
mvn -B release:perform \
59+
-Darguments="-DskipTests"
60+
61+
- name: Get artifact path
62+
id: artifact
63+
run: |
64+
ARTIFACT_PATH=$(find target/checkout/target -name "jmeter-copilot-plugin-${{ inputs.releaseVersion }}.jar" -type f | head -1)
65+
echo "path=$ARTIFACT_PATH" >> $GITHUB_OUTPUT
66+
echo "name=jmeter-copilot-plugin-${{ inputs.releaseVersion }}.jar" >> $GITHUB_OUTPUT
67+
68+
- name: Create GitHub Release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: v${{ inputs.releaseVersion }}
72+
name: Release v${{ inputs.releaseVersion }}
73+
body: |
74+
## JMeter Copilot Plugin v${{ inputs.releaseVersion }}
75+
76+
### Installation
77+
78+
1. Download `jmeter-copilot-plugin-${{ inputs.releaseVersion }}.jar` from the assets below
79+
2. Copy the JAR file to your JMeter `lib/ext` directory
80+
3. Restart JMeter
81+
82+
### Requirements
83+
84+
- Java 17 or later
85+
- Apache JMeter 5.6.3 or later
86+
- GitHub Copilot CLI installed and authenticated
87+
files: ${{ steps.artifact.outputs.path }}
88+
generate_release_notes: true

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# JMeter Copilot Plugin
22

3+
[![Build](https://github.com/brunoborges/jmeter-copilot/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/brunoborges/jmeter-copilot/actions/workflows/build.yml)
4+
35
An Apache JMeter plugin that provides a GitHub Copilot Chat experience for generating JMeter test plans through natural language conversation.
46

57
## Features
@@ -11,12 +13,34 @@ An Apache JMeter plugin that provides a GitHub Copilot Chat experience for gener
1113

1214
## Requirements
1315

14-
- Java 21 or later
16+
- Java 17 or later
1517
- Apache JMeter 5.6.3 or later
1618
- GitHub Copilot CLI installed and authenticated
1719
- [Copilot SDK for Java](https://github.com/github/copilot-sdk) (version 0.1.0)
1820

19-
## Building
21+
## Installation
22+
23+
### Quick Install (Recommended)
24+
25+
Download the latest release and install it to your JMeter installation with a single command:
26+
27+
```bash
28+
curl -sL $(curl -s https://api.github.com/repos/brunoborges/jmeter-copilot/releases/latest | grep "browser_download_url.*jar" | cut -d '"' -f 4) -o $JMETER_HOME/lib/ext/jmeter-copilot-plugin.jar
29+
```
30+
31+
Or, if you prefer to specify the JMeter path directly:
32+
33+
```bash
34+
curl -sL $(curl -s https://api.github.com/repos/brunoborges/jmeter-copilot/releases/latest | grep "browser_download_url.*jar" | cut -d '"' -f 4) -o /path/to/jmeter/lib/ext/jmeter-copilot-plugin.jar
35+
```
36+
37+
### Manual Installation
38+
39+
1. Download the latest JAR from [GitHub Releases](https://github.com/brunoborges/jmeter-copilot/releases/latest)
40+
2. Copy the JAR file to your JMeter `lib/ext` directory
41+
3. Restart JMeter
42+
43+
## Building from Source
2044

2145
### Prerequisites
2246

pom.xml

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>org.apache.jmeter.plugins</groupId>
@@ -12,10 +12,18 @@
1212
<name>JMeter Copilot Plugin</name>
1313
<description>JMeter plugin that integrates GitHub Copilot Chat for generating test plans</description>
1414

15+
<scm>
16+
<connection>scm:git:https://github.com/brunoborges/jmeter-copilot.git</connection>
17+
<developerConnection>scm:git:https://github.com/brunoborges/jmeter-copilot.git</developerConnection>
18+
<url>https://github.com/brunoborges/jmeter-copilot</url>
19+
<tag>HEAD</tag>
20+
</scm>
21+
1522
<properties>
16-
<maven.compiler.release>21</maven.compiler.release>
23+
<maven.compiler.release>17</maven.compiler.release>
1724
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1825
<jmeter.version>5.6.3</jmeter.version>
26+
<jmeter.home>${project.basedir}/../apache-jmeter-5.6.3</jmeter.home>
1927
</properties>
2028

2129
<dependencies>
@@ -38,22 +46,35 @@
3846
<version>${jmeter.version}</version>
3947
<scope>provided</scope>
4048
</dependency>
41-
49+
4250
<!-- GitHub Copilot SDK -->
4351
<dependency>
4452
<groupId>com.github.copilot</groupId>
4553
<artifactId>copilot-sdk</artifactId>
4654
<version>0.1.0</version>
4755
</dependency>
48-
56+
57+
<!-- Markdown rendering -->
58+
<dependency>
59+
<groupId>org.commonmark</groupId>
60+
<artifactId>commonmark</artifactId>
61+
<version>0.24.0</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.commonmark</groupId>
65+
<artifactId>commonmark-ext-gfm-tables</artifactId>
66+
<version>0.24.0</version>
67+
</dependency>
68+
4969
<!-- Google Auto Service for META-INF/services generation -->
70+
5071
<dependency>
5172
<groupId>com.google.auto.service</groupId>
5273
<artifactId>auto-service-annotations</artifactId>
5374
<version>1.1.1</version>
5475
<optional>true</optional>
5576
</dependency>
56-
77+
5778
<!-- SLF4J for logging -->
5879
<dependency>
5980
<groupId>org.slf4j</groupId>
@@ -69,6 +90,24 @@
6990
<version>5.14.1</version>
7091
<scope>test</scope>
7192
</dependency>
93+
<dependency>
94+
<groupId>org.mockito</groupId>
95+
<artifactId>mockito-core</artifactId>
96+
<version>5.20.0</version>
97+
<scope>test</scope>
98+
</dependency>
99+
<dependency>
100+
<groupId>org.mockito</groupId>
101+
<artifactId>mockito-junit-jupiter</artifactId>
102+
<version>5.20.0</version>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>org.assertj</groupId>
107+
<artifactId>assertj-core</artifactId>
108+
<version>3.27.6</version>
109+
<scope>test</scope>
110+
</dependency>
72111
</dependencies>
73112

74113
<build>
@@ -133,36 +172,31 @@
133172
</plugin>
134173
<plugin>
135174
<groupId>org.apache.maven.plugins</groupId>
136-
<artifactId>maven-antrun-plugin</artifactId>
137-
<version>3.2.0</version>
138-
<executions>
139-
<execution>
140-
<id>copy-to-jmeter</id>
141-
<phase>package</phase>
142-
<goals>
143-
<goal>run</goal>
144-
</goals>
145-
<configuration>
146-
<target>
147-
<copy file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
148-
todir="${project.basedir}/../apache-jmeter-5.6.3/lib/ext"/>
149-
</target>
150-
</configuration>
151-
</execution>
152-
</executions>
175+
<artifactId>maven-release-plugin</artifactId>
176+
<version>3.3.1</version>
177+
<configuration>
178+
<tagNameFormat>v@{project.version}</tagNameFormat>
179+
<autoVersionSubmodules>true</autoVersionSubmodules>
180+
<releaseProfiles>release</releaseProfiles>
181+
</configuration>
153182
</plugin>
154183
</plugins>
155184
</build>
156185

157186
<profiles>
158187
<profile>
159188
<id>install-to-jmeter</id>
189+
<activation>
190+
<file>
191+
<exists>${jmeter.home}/bin/jmeter</exists>
192+
</file>
193+
</activation>
160194
<build>
161195
<plugins>
162196
<plugin>
163197
<groupId>org.apache.maven.plugins</groupId>
164198
<artifactId>maven-antrun-plugin</artifactId>
165-
<version>3.1.0</version>
199+
<version>3.2.0</version>
166200
<executions>
167201
<execution>
168202
<id>copy-to-jmeter</id>
@@ -172,8 +206,9 @@
172206
</goals>
173207
<configuration>
174208
<target>
175-
<copy file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
176-
todir="${jmeter.home}/lib/ext"/>
209+
<copy
210+
file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
211+
todir="${jmeter.home}/lib/ext" />
177212
</target>
178213
</configuration>
179214
</execution>
@@ -183,4 +218,4 @@
183218
</build>
184219
</profile>
185220
</profiles>
186-
</project>
221+
</project>

0 commit comments

Comments
 (0)