小编Fra*_* H.的帖子

Visual Studio Express 2013:单元测试中的程序输出(控制台,调试等)

我真是在这里撞墙.在Visual Studio(Express 2013)中获取程序输出是如此困难吗?在编写代码时,我发现在工作和故障排除时能够打印出变量,操作等的值是绝对必要的.

在Java和Eclipse中,System.out.println()总是有效,打印到IDE控制台.在编写C程序时,我总是使用控制台,所以回声任何事都没问题.但是,在VS Express 2013中我似乎无法获得任何输出.

问题可能与我正在编写单元测试而不是"正常"可执行程序这一事实有关吗?如果是这样,有没有办法让VS在单元测试类中显示程序输出?我尝试过使用调试,但这也没有显示任何内容.认为存在配置问题,我已经找到了调试未显示的消息的解决方案,但我找到的任何选项(在这里或其他地方)似乎没有帮助.

或者,当然 - 如果在VS/C#中编写代码时有另一种常用的方法来检查程序值,输出等,我想听听它:-)

有人有任何想法吗?如果问题太不明确或者其他问题,请告诉我,我会解决它.

注意:我正在使用单元测试类进行功能测试,以防有人想指出我应该做什么,而不应该做单元测试.

编辑1:我忘了提到我无法使用"Start:Debug"运行代码.如果我尝试,我会收到此错误:"无法直接启动具有类库输出类型的项目." (单元测试项目使用另一个项目中的类,即类库项目.)这当然是因为我在解决方案中没有可执行项目.我运行它的方法是从Test Explorer运行选定的测试.

编辑2:代码:

using System;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WordpressAutomation;

namespace WordpressTests
{

    [TestClass]
    public class LoginTests : WordpressTest {

        [TestMethod]
        public void AdminUserCanLogIn() {

            System.Diagnostics.Debug.WriteLine("Something...");
            System.Diagnostics.Trace.WriteLine("Something...");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# unit-testing visual-studio-express output visual-studio-2013

15
推荐指数
3
解决办法
2万
查看次数

VS 2017 和 Selenium.Webdriver NuGet:找不到 chromedriver.exe

我一直在 Visual Studio 2015 中使用 Selenium Webdriver 的 NuGet 包,并取得了巨大成功。我没有下载 chromedriver.exe 文件并手动添加它,而是通过 NuGet 完成了所有操作。

现在,在 VS 2017 中,这不再起作用了。

我添加了所有必需的 NuGet 包:Selenium.WebDriver (3.11.1) 和 Selenium.Chrome.WebDriver (2.37.0)。

但是,当我尝试实例化驱动程序并打开 Chrome 时,出现以下异常:

OpenQA.Selenium.DriverServiceNotFoundException: 'The chromedriver.exe file
does not exist in the current directory or in a directory on the PATH 
environment variable. The driver can be downloaded at 
http://chromedriver.storage.googleapis.com/index.html.'
Run Code Online (Sandbox Code Playgroud)

使用 NuGet(至少在这种情况下)的全部要点是不要手动下载和添加驱动程序。但为什么这个会坏呢?

为了简洁起见,这里是我用来实例化 chromedriver 的测试代码:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program {
    public static IWebDriver Instance { get; set; }
    static void Main (string[] args) …
Run Code Online (Sandbox Code Playgroud)

selenium-chromedriver selenium-webdriver visual-studio-2017

5
推荐指数
1
解决办法
2821
查看次数