Skip to content

Test Case

Akira Kashihara edited this page May 14, 2022 · 34 revisions

Introduction

The purpose of this wiki is to clarify the policy of test in order to make a test case.

How to Make The Test Case? (The Policy and Flow for Test)

We make the test case by following the steps below.

  1. Equivalence partitioning
  2. Boundary value analysis
  3. All-pairs testing (Pairwise testing)* * If the module to be tested has too many input combination.

The Test Case

This chapter lists the test case for each module(class and method).

The Table of Test Case List

Class Method Test Case Valid or Invalid Implementation
GCS constructor Assumed valid parameter, Check instance variables Valid ✅
GCS getAccessToken location has hash and access_token Valid ✅
GCS getAccessToken location has hash but it does not have access_token Valid ✅
GCS getAccessToken location does not have hash Valid ✅
GCS getAccessToken location is an empty Object Valid ✅
GCS getAccessToken Invalid argument is number Invalid ✅
GCS getAccessToken Invalid argument is Boolean Invalid ✅
GCS getAccessToken Invalid argument is null Invalid ✅
GCS getAccessToken Invalid argument is undefined Invalid ✅
GCS getAccessToken Invalid argument is BigInt Invalid ✅
GCS getAccessToken Invalid argument is Symbol Invalid ✅
GCS getAccessToken Invalid argument is String Invalid ✅
GCS setCred Assumed valid parameter Valid ✅
GCS setCred Invalid input parameter, params.clientId is number Invalid ✅
GCS setCred Invalid input parameter, params.clientId is Boolean Invalid ✅
GCS setCred Invalid input parameter, params.clientId is null Invalid ✅
GCS setCred Invalid input parameter, params.clientId is undefined Invalid ✅
GCS setCred Invalid input parameter, params.clientId is BigInt Invalid ✅
GCS setCred Invalid input parameter, params.clientId is Symbol Invalid ✅
GCS setCred Invalid input parameter, params.clientId is Object Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is number Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is Boolean Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is null Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is undefined Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is BigInt Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is Symbol Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is String(not URL) Invalid ✅
GCS setCred Invalid input parameter, params.redirectUrl is Object Invalid ✅
GCS setCred Invalid input parameter, params.scope is number Invalid ✅
GCS setCred Invalid input parameter, params.scope is Boolean Invalid ✅
GCS setCred Invalid input parameter, params.scope is null Invalid ✅
GCS setCred Invalid input parameter, params.scope is undefined Invalid ✅
GCS setCred Invalid input parameter, params.scope is BigInt Invalid ✅
GCS setCred Invalid input parameter, params.scope is Symbol Invalid ✅
GCS setCred Invalid input parameter, params.scope is String(not scope URL) Invalid ✅
GCS setCred Invalid input parameter, params.scope is String(not URL) Invalid ✅
GCS setCred Invalid input parameter, params.scope is Object Invalid ✅
GCS uploadFile All parameters are fine Valid ✅
GCS uploadFile fetch is failed Valid ✅
GCS uploadFile fetch result does not include mediaLink Valid ✅
GCS uploadFile event.target.result is not set Invalid ✅
GCS uploadFile event.target is not set Invalid ✅
GCS uploadFile event is not set Invalid ✅
GCS uploadFile this.bucketName is not set Invalid ✅
GCS uploadFile this.file is not set Invalid ✅
GCS uploadFile this.token is not set Invalid ✅
GCS uploadFile fileName includes "&" Invalid ✅
GCS uploadFile fileName includes "=" Invalid ✅
GCS uploadFile fileName includes "?" Invalid ✅
GCS uploadFile fileName includes "/" Invalid ✅
GCS uploadFiles fileList(more than 2 files), bucketName are valid without accessToken Valid ✅
GCS uploadFiles fileList(more than 2 files), bucketName and accessToken are valid Valid ✅
GCS uploadFiles fileList(only one file), bucketName are valid without accessToken Valid ✅
GCS uploadFiles fileList(only one file), bucketName and accessToken are valid Valid ✅
GCS uploadFiles The first argument is not FileList (number) Invalid ✅
GCS uploadFiles The first argument is not FileList (Boolean) Invalid ✅
GCS uploadFiles The first argument is not FileList (undefined) Invalid ✅
GCS uploadFiles The first argument is not FileList (String) Invalid ✅
GCS uploadFiles The first argument is not FileList (BigInt) Invalid ✅
GCS uploadFiles The first argument is not FileList (Symbol) Invalid ✅
GCS uploadFiles The first argument is not FileList (Object) Invalid ✅
GCS uploadFiles The first argument is not FileList (File) Invalid ✅
ToolKit detectURL http://localhost Valid ✅
ToolKit detectURL http://localhost:3000 Valid ✅
ToolKit detectURL http://localhost/hogehoge Valid ✅
ToolKit detectURL http://localhost:3000/hogehoge Valid ✅
ToolKit detectURL http://localhost/hogehoge/hoge Valid ✅
ToolKit detectURL http://localhost:3000/hogehoge/hoge Valid ✅
ToolKit detectURL https://hacknock.com Valid ✅
ToolKit detectURL https://test.hacknock.com Valid ✅
ToolKit detectURL https://leadyou.test.hacknock.com Valid ✅
ToolKit detectURL https://hacknock.com/hoge/hogehoge Valid ✅
ToolKit detectURL https://test.hacknock.com/hoge/hogehoge Valid ✅
ToolKit detectURL https://leadyou.test.hacknock.com/hoge/hogehoge Valid ✅
ToolKit detectURL http://localhos Invalid ✅
ToolKit detectURL http://locahost:3000 Invalid ✅
ToolKit detectURL http://lcalhost/hogehoge Invalid ✅
ToolKit detectURL http://ocalhost:3000/hogehoge Invalid ✅
ToolKit detectURL http://localhost3000 Invalid ✅
ToolKit detectURL http://hacknock.com Invalid ✅
ToolKit detectURL https://hacknock Invalid ✅
ToolKit detectURL http://leadyou.test.hacknock.com Invalid ✅
ToolKit detectURL http://hacknock.com/hoge Invalid ✅
ToolKit detectURL http://test.hacknock.com/hoge Invalid ✅
ToolKit detectURL http://leadyou.test.hacknock.com/hoge Invalid ✅
ToolKit detectURL http://hacknock.com/hoge/hogehoge Invalid ✅
ToolKit detectURL http://test.hacknock.com/hoge/hogehoge Invalid ✅
ToolKit detectURL http://leadyou.test.hacknock.com/hoge/hogehoge Invalid ✅

Clam

Constructor

Clam(params, name = "GCS");

Equivalence Partitioning

Valid

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: string(URL)],
}
name = "GCS"

OUTPUT

return Object

ASSERTION

OUTPUT.name === "GCS"
typeof OUTPUT.getAuth === "function"
typeof OUTPUT.getAuthInfo === "function"
typeof OUTPUT.uploadFiles === "function"

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: string(URL)],
}

OUTPUT

return Object

ASSERTION

OUTPUT.name === "GCS"
typeof OUTPUT.getAuth === "function"
typeof OUTPUT.getAuthInfo === "function"
typeof OUTPUT.uploadFiles === "function"
Invalid

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: string(URL)],
}
name = [name: number, Boolean, null, undefined, BigInt, String(not "GCS"), Symbol, Object]

OUTPUT

throw Error("'name' value is invalid. You must input 'GCS'")

ASSERTION

toThrowError("'name' value is invalid. You must input 'GCS'")

INPUT

params = {
  clientId: [client ID: number, Boolean, null, undefined, BigInt, Symbol, Object],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: string(URL)],
}
name = [name: string]

OUTPUT

throw Error("params.clientId is invalid. You must input string value.")

ASSERTION

toThrowError("params.clientId is invalid. You must input string value.")

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: number, Boolean, null, undefined, BigInt, String(not URL), Symbol, Object],
  scope: [scope: string(URL)],
}
name = [name: string]

OUTPUT

throw Error("params.redirectUrl is invalid. You must input string value which is URL.")

ASSERTION

toThrowError("params.redirectUrl is invalid. You must input string value which is URL.")

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: number, Boolean, null, undefined, BigInt, String(not URL), Symbol, Object],
}
name = [name: string]

OUTPUT

throw Error("params.scope is invalid. You must input string value which is URL.")

ASSERTION

toThrowError("params.scope is invalid. You must input string value which is URL.")

Boundary Value Analysis

getAuth

Equivalence Partitioning

Boundary Value Analysis

getAuthInfo

Equivalence Partitioning

Boundary Value Analysis

uploadFiles

Equivalence Partitioning

Boundary Value Analysis

GCS

setCred

setCred(params)

Equivalence Partitioning

Valid

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: string(scope URL)*],
}

* scopes list

OUTPUT

return Object

ASSERTION

    expect(OUTPUT.info).toBe(params);
    expect(OUTPUT.accessToken).toBeNull();
Invalid

INPUT

params = {
  clientId: [client ID: number, Boolean, null, undefined, BigInt, Symbol, Object],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: string(scope URL)*],
}

* scopes list

OUTPUT

throw Error("params.clientId is invalid value. You must set String value.");

ASSERTION

.toThrow("params.clientId is invalid value. You must set String value.");

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: number, Boolean, null, undefined, BigInt, Symbol, String(not URL), Object],
  scope: [scope: string(scope URL)*],
}

* scopes list

OUTPUT

throw Error("params.redirectUrl is invalid value. You must set string value which is an URL.");

ASSERTION

.rejects.toThrow("params.redirectUrl is invalid value. You must set string value which is an URL.");

* scopes list

INPUT

params = {
  clientId: [client ID: string],
  redirectUrl: [redirect URL: string(URL)],
  scope: [scope: number, Boolean, null, undefined, BigInt, Symbol, String(not scope URL, not URL), Object],
}

OUTPUT

throw Error("params.scope is invalid value. You must set string value which is a URL in scopes. A list of scopes is in https://cloud.google.com/storage/docs/authentication .");

ASSERTION

.rejects.toThrow("params.scope is invalid value. You must set string value which is a URL in scopes. A list of scopes is in https://cloud.google.com/storage/docs/authentication .");

Boundary Value Analysis

oauthSignIn

Equivalence Partitioning

Boundary Value Analysis

getAccessToken

Equivalence Partitioning

Valid

INPUT

      const url = "http://localhost";
      const dummyToken = crypto
        .randomBytes(160)
        .toString("hex")
        .substring(0, 160);
      const dummyJoint = crypto.randomBytes(4).toString("hex").substring(0, 4);
      Object.defineProperty(window, "location", {
        value: {
          href: `${url}/#state=pass-through%20value&access_token=${dummyJoint}.${dummyToken}&token_type=Bearer&expires_in=1000&scope=https://www.googleapis.com/auth/devstorage.read_only`,
          hash: `#state=pass-through%20value&access_token=${dummyJoint}.${dummyToken}&token_type=Bearer&expires_in=1000&scope=https://www.googleapis.com/auth/devstorage.read_only`,
          configurable: true,
        },
      });

OUTPUT

return { token: `${dummyJoint}.${dummyToken}` }

ASSERTION

.toStrictEqual({ token: `${dummyJoint}.${dummyToken}` })

INPUT

      const url = "http://localhost";
      Object.defineProperty(window, "location", {
        value: {
          href: `${url}/#state=pass-through%20value`,
          hash: "#state=pass-through%20value",
          configurable: true,
        },
      });

OUTPUT

return {
        token: null,
        message: "This location has no access token info.",
      }

ASSERTION

.toStrictEqual({
        token: null,
        message: "This location has no access token info.",
      });

INPUT

      const url = "http://localhost";
      Object.defineProperty(window, "location", {
        value: {
          href: url,
          configurable: true,
        },
      });

OUTPUT

return {
        token: null,
        message: "This location has no access token info.",
      }

ASSERTION

.toStrictEqual({
        token: null,
        message: "This location has no access token info.",
      });

INPUT

      delete window.location.href;
      delete window.location.hash;
      delete window.location.token;
      delete window.location.configurable;

OUTPUT

return {
        token: null,
        message: "This location has no access token info.",
      }

ASSERTION

.toStrictEqual({
        token: null,
        message: "This location has no access token info.",
      });
Invalid

INPUT

const argument = [number, Boolean, null, undefined, String, BigInt, Symbol]

OUTPUT

throw Error("You must input location which is Object.");

ASSERTION

.toThrow(/^You must input location which is Object.$/);

INPUT

const argument = null

OUTPUT

throw Error(
        "The argument is null.You must input location which is Object, not null."
      );

ASSERTION

.toThrow(
        /^The argument is null.You must input location which is Object, not null.$/
      );

uploadFile

Equivalence Partitioning

Valid

INPUT

  • Argument
    • event
      • event.target.result = "hogehoge"
  • Bind
    • bucketName: bucketName = "hogehoge"
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function without error.

ASSERTION

        callback: (err, fileName) => {
          expect(err).toBeNull();
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

INPUT

  • Argument
    • event
      • event.target.result = "hogehoge"
  • Bind
    • bucketName: bucketName = "hogehoge"
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function with error. Error message is "404 Error occurred by fetch."

ASSERTION

        callback: (err, fileName) => {
          expect(err).toBe("404 Error occurred by fetch.");
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

INPUT

  • Argument
    • event
      • event.target.result = "hogehoge"
  • Bind
    • bucketName: bucketName = "hogehoge"
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function with error. Error message is "No mediaLink"

ASSERTION

        callback: (err, fileName) => {
          expect(err).toBe("No mediaLink");
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },
Invalid

INPUT

  • Argument
    • event.target = "hogehoge"
  • Bind
    • bucketName: bucketName = "hogehoge"
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function with error. Error message is "The argument is empty or the event does not include 'event.target.result.'"

ASSERTION

callback: (err, fileName) => {
          expect(err).toBe(
            "The argument is empty or the event does not include 'event.target.result.'"
          );
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

INPUT

  • Argument
    • event = "hogehoge"
  • Bind
    • bucketName: bucketName = "hogehoge"
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function with error. Error message is "The argument is empty or the event does not include 'event.target.result.'"

ASSERTION

callback: (err, fileName) => {
          expect(err).toBe(
            "The argument is empty or the event does not include 'event.target.result.'"
          );
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

INPUT

  • Bind
    • bucketName: bucketName = "hogehoge"
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function with error. Error message is "The argument is empty or the event does not include 'event.target.result.'"

ASSERTION

callback: (err, fileName) => {
          expect(err).toBe(
            "The argument is empty or the event does not include 'event.target.result.'"
          );
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

INPUT

  • Argument
    • event
      • event.target.result = "hogehoge"
  • Bind
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function output an error which is "bucketName is not binded. Please set bucketName.".

ASSERTION

        callback: (err, fileName) => {
          expect(err).toBe("bucketName is not binded. Please set bucketName.");
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

INPUT

  • Argument
    • event
      • event.target.result = "hogehoge"
  • Bind
    • bucketName: bucketName = "hogehoge"
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function output error. "file is not set. Please bind file."

ASSERTION

        callback: (err, fileName) => {
          expect(err).toBe("file is not set. Please bind file.");
          expect(fileName).toBeNull();
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

INPUT

  • Argument
    • event
      • event.target.result = "hogehoge"
  • Bind
    • bucketName: bucketName = "hogehoge"
    • file: file = new File(["foo"], "foo.txt", {type: "text/plain"});
    • token: "j30f23jf023f"
    • callback:
(err, fileName) => {
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        }

OUTPUT

callback function throws error. "token is not set. Please bind token"

ASSERTION

        callback: (err, fileName) => {
          expect(err).toBe("token is not set. Please bind token");
          expect(fileName).toBe("foo.txt");
          if (err) {
            console.error("failure: " + fileName);
            console.error(err);
          } else {
            console.log("success: " + fileName);
          }
        },

uploadFiles

Equivalence Partitioning

Valid

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

Invalid

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

INPUT


OUTPUT

ASSERTION

Boundary Value Analysis

Clone this wiki locally