是否可以从量角器测试中调用C#代码?

Gar*_*ill 3 c# unit-testing angularjs protractor

我想用C#实现我的Protractor单元测试的一部分.这可能吗?

原因是我想从我的数据库中提取一些数据并将其与存储在文本文件中的预期结果进行比较.在JavaScript中执行此操作涉及太多繁重的工作.所以,我想调用一个C#DLL或EXE来做这个部分.

Jos*_*osh 5

您可以使用Edge.js执行此操作

最终Protractor在一个节点进程内运行,因此你可以用节点做任何事情,你可以用Protractor做.

你只需要安装边缘:

npm install edge -g

然后需要它并在spec文件中使用.Net代码执行某些操作:

var edge = require('edge');

var hello = edge.func(function () {/*
 async (input) => {
 return "CSharp welcomes " + input.ToString();
 }
 */});

describe('.Net is in your node!', function(){

  beforeEach(function(){
    hello('Node.js', function (error, result) {
      if (error) throw error;
      console.log(result);
    });
  });

});
Run Code Online (Sandbox Code Playgroud)