本文へスキップ
Testing

Panduan bug report dan reproduksi untuk proyek pemula

Pelajari cara mencatat bug agar mudah direproduksi, diverifikasi, dan diperbaiki nanti.

公開日: 2026-06-23#bug report#reproduction#debugging#beginner

Quick Start

Mulai dari versi kecil yang berjalan

Banyak bug fix macet bukan karena bug-nya mustahil diperbaiki, tetapi karena masalah awal dicatat terlalu samar. Untuk pemula, empat informasi saja sangat membantu: gejala, lokasi, langkah reproduksi, dan hasil yang seharusnya terjadi.

Bangun dengan potongan kode kecil

1. 値を用意する

Inspectorで変更できる値と表示先を置きます。

BugReproTutorial.cs
csharp
    [SerializeField] private TextMeshProUGUI statusText;
    [SerializeField] private float stepCount = 1f;
    [SerializeField] private float errorCount = 2f;
    [SerializeField] private float logLineCount = 3f;

2. 状態を変える

ボタンを押した時に、1つだけ状態を進めます。

BugReproTutorial.cs
csharp
    public void NextStep()
    {
        step = (step + 1) % 3;
        var label = step == 0 ? "症状を記録" : step == 1 ? "手順を並べる" : "ログを添える";
        if (statusText != null)
        {
            statusText.text = $"{label}\nstepCount={stepCount:0.##}\nerrorCount={errorCount:0.##}\nlogLineCount={logLineCount:0.##}";
        }

3. 画面に表示する

変わった結果を画面に出して確認します。

BugReproTutorial.cs
csharp
        if (statusText != null)
        {
            statusText.text = $"{label}\nstepCount={stepCount:0.##}\nerrorCount={errorCount:0.##}\nlogLineCount={logLineCount:0.##}";
        }
        Debug.Log($"バグ報告と再現手順: {label}");

Script lengkap

BugReproTutorial.cs
csharp
using UnityEngine;
using TMPro;

public class BugReproTutorial : MonoBehaviour
{
    [SerializeField] private TextMeshProUGUI statusText;
    [SerializeField] private float stepCount = 1f;
    [SerializeField] private float errorCount = 2f;
    [SerializeField] private float logLineCount = 3f;

    private int step;

    public void NextStep()
    {
        step = (step + 1) % 3;
        var label = step == 0 ? "症状を記録" : step == 1 ? "手順を並べる" : "ログを添える";
        if (statusText != null)
        {
            statusText.text = $"{label}\nstepCount={stepCount:0.##}\nerrorCount={errorCount:0.##}\nlogLineCount={logLineCount:0.##}";
        }
        Debug.Log($"バグ報告と再現手順: {label}");
    }
}

Inspector

Hubungkan referensi UI di Inspector, lalu cek setiap perubahan dengan tombol.

Ringkasan

Hal yang perlu dibawa pulang

Pelajari cara mencatat bug agar mudah direproduksi, diverifikasi, dan diperbaiki nanti.