我正在尝试创建"Angular.js in Action"中描述的Jasmine单元测试.该应用程序运行正常但我在尝试运行我的测试时在node.js命令提示符中不断收到此错误.
我的配置:
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'javascripts/angular.min.js',
'javascripts/angular-mocks.js',
'javascripts/app.js',
'tests/angelloModelSpec.js',
],
Run Code Online (Sandbox Code Playgroud)
我的index.html标题:
<head>
<script src="javascripts/angular.min.js" type="text/javascript"></script>
<script src="javascripts/angular-mocks.js"></script>
<script src="javascripts/app.js"></script>
<meta charset="utf-8">
<title>Angello</title>
<meta name="description" content="Angello Story Application">
<link rel="stylesheet" href="app.css">
</head>
Run Code Online (Sandbox Code Playgroud)
我的测试:
describe('Service: angelloModel', function(){
// load the service's module
beforeEach(module('Angello'));
var modelService; …Run Code Online (Sandbox Code Playgroud) (编辑**我能够获得编译和执行单元测试的代码.除了代码修复,VS2010无限期地运行单元测试时出现问题.我不得不替换已更改的dll文件在vs 2012的中止安装期间.我将更改发布到页面底部的控制器和单元测试.感谢所有发布答案的人.)
这是我在网上询问有关编码的第一个问题.我用免费教程学习C#.NET和其他相关的东西大约一年了.到目前为止,我已经能够自己研究和解决所有问题.我现在开始冒险进入未知领域,我似乎无法找到答案.
我一直在研究一个名为"在7天内逐步学习MVC模型视图控制器"的教程.链接如下:http: //www.codeproject.com/Articles/259560/Learn-MVC-Model-view-controller-Step-by-Step-in-7
我已经研究了错误的建议链接:
Error 'Mvccustomer.Models.Customer' does not contain a definition for 'DisplayCustomer' and no extension method 'DisplayCustomer' accepting a first argument of type 'Mvccustomer.Models.Customer' could be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我似乎无法找到类似的情况,其中有人正在使用类似的文件引用创建单元测试.请注意,我对MVC和单元测试完全不熟悉.
本教程的一个问题是,在视频中,作者使用了一组命名空间/文件名,而另一组则在书面教程中.我能够自己解决这个问题.例如,在开始时,他使用"Mvccustomer"作为项目名称,但在第一天的第4或第5实验室,他称之为"Mvcinputscreen".我认为问题在于如何在项目中引用客户类,但到目前为止我无法弄清楚.
这是给我一个错误的单元测试:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mvccustomer.Models;
namespace MvcUnitTest
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void DisplayCustomer()
{
Customer obj = new Customer();
var varresult = obj.DisplayCustomer();
Assert.AreEqual("DisplayCustomer", …Run Code Online (Sandbox Code Playgroud)