Skip to content

Adding test cases for autorest.testserver

Travis Prescott edited this page Dec 30, 2020 · 7 revisions
  1. The test server swagger should be in {your repo}./node_modules/@microsoft.azure/autorest.testserver/swagger. If there is no such directory in your repo, run npm install.

  2. Script scripts/testserver_codegen.py is used to regenerate test code for each check-in. To add a new test case, you just need to add the name swagger file (exclude the file extension '.json' to this array in the script.

    files=( "head" "body-file" "report" "xms-error-responses" "body-integer")

  3. The generated files will be under a new directory {your repo}/test/integration/generated

  4. Drag the folder containing the Package.swift of the generated code to the XCode workspace under AutorestSwiftTest to create dependency.

  5. In the AutorestSwiftTest target Build Phases, add the new test package in the section Link Binary with Libraries.

  6. Open the Package.swift file for AutorestSwift and add a line to dependencies for the new test case. It will look like:

    .package(name: "AutoRestHeadTest", path: "./test/integration/generated/head/"),

  7. Also in Package.swift, add the name of the test package to the .testTarget dependencies for AutorestSwiftTest.

  8. Add a new test case in AutorestSwiftTest. The naming convention is {Package name created}Test.swift. Add your test logic to the new test case.

Clone this wiki locally