GithubHelp home page GithubHelp logo

isabella232 / azure-functions-tests Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/azure-functions-tests

0.0 0.0 0.0 358 KB

Demonstrates how to run automated tests in C# and JavaScript

License: MIT License

C# 100.00%

azure-functions-tests's Introduction

page_type languages products description urlFragment
sample
csharp
azure
This repository includes examples demonstrating how to run tests against an HTTP-triggered and timer-triggered function in both C# and JavaScript.
azure-functions-tests

Testing Azure Functions

This repository includes examples demonstrating how to run tests against an HTTP-triggered and timer-triggered function in both C# and JavaScript. The C# implementation uses xUnit in Visual Studio and the JavaScript examples use Jest for automated tests and works best with Visual Studio Code.

There are two functions with associated tests available for both environments, these examples include:

  • HTTP-triggered function: The example demonstrates how to pass in query string parameters to the function. The C# example uses xUnit's Theory feature to pass in a data set to the HTTP triggered function.
  • Timer-triggered function: A non-HTTP triggered function (in the form of a timer-triggered function) is included to demonstrate how to test a function that is not callable via a standard HTTP request.

To read more about the samples featured in this repo, read Strategies for testing your code in Azure Functions

C# in Visual Studio

To run the C# tests open the file csharp-visualstudio\FunctionsTesting.sln in Visual Studio. After you have restored all the dependencies, build the solution and click Run All from the Test Explorer. The output from the tests should look something like the following:

Visual Studio Tests

To debug your tests, set a breakpoint in your code navigate to the Test Explorer. Then, click Run... > Debug Last Run.

JavaScript in VS Code

Open the folder javascript-vscode in VS Code. Run npm install to install the dependencies and then run npm test to run the tests. The output from the tests should look something like the following:

VS Code Tests

To debug you tests, set a break point in your code and add the following configuration to launch.json before starting a debug session.

{
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Debug Tests",
      "program": "${workspaceRoot}\\node_modules\\jest\\bin\\jest.js",
      "args": [
          "-i"
      ],
      "internalConsoleOptions": "openOnSessionStart"
    }
  ]
}

azure-functions-tests's People

Contributors

craigshoemaker avatar microsoftopensource avatar msftgits avatar v-rajagt-zz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.