diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..5116e65 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,51 @@ +name: E2E Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + inputs: + test_class: + description: 'Specific test class to run (e.g., DummyTest). Leave empty to run all.' + required: false + type: string + +jobs: + e2e-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: '8' + cache: 'gradle' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run E2E tests + env: + KINTONE_BASE_URL: ${{ secrets.KINTONE_BASE_URL }} + KINTONE_DEFAULT_USER: ${{ secrets.KINTONE_DEFAULT_USER }} + KINTONE_DEFAULT_PASSWORD: ${{ secrets.KINTONE_DEFAULT_PASSWORD }} + KINTONE_TEST_USER: ${{ secrets.KINTONE_TEST_USER }} + KINTONE_TEST_PASSWORD: ${{ secrets.KINTONE_TEST_PASSWORD }} + KINTONE_SPACE_ID: ${{ secrets.KINTONE_SPACE_ID }} + KINTONE_GUEST_SPACE_ID: ${{ secrets.KINTONE_GUEST_SPACE_ID }} + KINTONE_BASIC_USER: ${{ secrets.KINTONE_BASIC_USER }} + KINTONE_BASIC_PASS: ${{ secrets.KINTONE_BASIC_PASS }} + TEST_CLASS: ${{ inputs.test_class }} + run: | + if [ -n "$TEST_CLASS" ]; then + ./gradlew :e2e-tests:test --tests "*.$TEST_CLASS" + else + ./gradlew :e2e-tests:test + fi diff --git a/README.md b/README.md index a7f9783..7e71a4b 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,27 @@ Run the following command to build a JAR file of this library. $ ./gradlew clean jar ``` +## E2E Tests + +E2E tests require a kintone environment. Set the following environment variables and run: + +```bash +# Required environment variables +export KINTONE_BASE_URL=https://your-domain.cybozu.com +export KINTONE_DEFAULT_USER=your-user +export KINTONE_DEFAULT_PASSWORD=your-password +export KINTONE_TEST_USER=test-user +export KINTONE_TEST_PASSWORD=test-password +export KINTONE_SPACE_ID=your-space-id +export KINTONE_GUEST_SPACE_ID=your-guest-space-id + +# Run all E2E tests +./gradlew :e2e-tests:test + +# Run a specific test class +./gradlew :e2e-tests:test --tests "*.YourTestClass" +``` + ## Contribution Guide - [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/e2e-tests/.gitignore b/e2e-tests/.gitignore new file mode 100644 index 0000000..b619459 --- /dev/null +++ b/e2e-tests/.gitignore @@ -0,0 +1,10 @@ +.gradle/ +build/ +# bin/ is used for scripts, not Eclipse build output +!bin/ +bin/test/ +.env +kintone-java-client.jar +.classpath +.project +.settings/ diff --git a/e2e-tests/README.md b/e2e-tests/README.md new file mode 100644 index 0000000..f7f1cfe --- /dev/null +++ b/e2e-tests/README.md @@ -0,0 +1,52 @@ +# E2E Tests + +End-to-end tests for kintone-java-client that run against a real kintone environment. + +## Prerequisites + +- Java 8 or later +- A kintone environment for testing + +## Environment Variables + +Set the following environment variables before running tests: + +| Variable | Description | +|----------|-------------| +| `KINTONE_BASE_URL` | Base URL of your kintone environment | +| `KINTONE_DEFAULT_USER` | Default user login name | +| `KINTONE_DEFAULT_PASSWORD` | Default user password | +| `KINTONE_TEST_USER` | Test user login name | +| `KINTONE_TEST_PASSWORD` | Test user password | +| `KINTONE_SPACE_ID` | Space ID for testing | +| `KINTONE_GUEST_SPACE_ID` | Guest space ID for testing | +| `KINTONE_BASIC_USER` | Basic auth username (if enabled) | +| `KINTONE_BASIC_PASS` | Basic auth password (if enabled) | + +## Running Tests + +From the project root directory: + +```bash +# Run all E2E tests +./gradlew :e2e-tests:test + +# Run a specific test class +./gradlew :e2e-tests:test --tests "*.RecordApiTest" + +# Run with environment variables inline +KINTONE_BASE_URL=https://example.cybozu.com \ +KINTONE_DEFAULT_USER=user \ +KINTONE_DEFAULT_PASSWORD=pass \ +./gradlew :e2e-tests:test +``` + +## CI/CD + +Tests are automatically run via GitHub Actions: + +- On push to `master` branch +- On pull requests to `master` branch +- Manually via workflow dispatch (with optional specific test class) + +See `.github/workflows/e2e.yml` for the workflow configuration. diff --git a/e2e-tests/build.gradle b/e2e-tests/build.gradle new file mode 100644 index 0000000..97b607c --- /dev/null +++ b/e2e-tests/build.gradle @@ -0,0 +1,24 @@ +plugins { + id 'java' +} + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + implementation project(':') + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' + testImplementation 'org.assertj:assertj-core:3.26.0' + + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' +} + +test { + useJUnitPlatform() + jvmArgs '-Duser.timezone=Asia/Tokyo' +} diff --git a/e2e-tests/src/test/java/com/kintone/client/DummyTest.java b/e2e-tests/src/test/java/com/kintone/client/DummyTest.java new file mode 100644 index 0000000..2500772 --- /dev/null +++ b/e2e-tests/src/test/java/com/kintone/client/DummyTest.java @@ -0,0 +1,16 @@ +package com.kintone.client; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Dummy test for E2E workflow verification") +class DummyTest { + + @Test + @DisplayName("Placeholder test - replace with real E2E tests in Phase 2") + void dummyTest() { + assertThat(true).isTrue(); + } +} diff --git a/settings.gradle b/settings.gradle index 15b9937..8caf6d7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,3 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * The settings file is used to specify which projects to include in your build. - * - * Detailed information about configuring a multi-project build in Gradle can be found - * in the user manual at https://docs.gradle.org/5.6.2/userguide/multi_project_builds.html - */ - rootProject.name = 'kintone-java-client' + +include 'e2e-tests'