当单元测试用例与其他单元测试用例一起运行时,键入初始化异常 [英] Type initialization exception when the unit test case runs with other unit test cases

查看:86
本文介绍了当单元测试用例与其他单元测试用例一起运行时,键入初始化异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在运行带有其他测试用例的测试用例时,我在使用静态类方法的地方得到了一个Type初始化异常。但是,当我单独运行测试用例时,我没有得到异常并且测试用例正在通过。我无法找到任何解决方案。请指导我如何解决这个问题!



我尝试过:



尝试搜索但无法找到任何解决方案

I am getting a Type initialization exception at the place where static class's method is getting used when I run the test case with other test cases. However, when I run the test case alone I am not getting the exception and the test case is passing. I am unable to find any solution. Please guide me on how to resolve this!

What I have tried:

Tried searching but couldnt find any solution

推荐答案

看起来像是线程/并发问题。确保您的代码(特别是在该静态类中)是线程安全的。
Looks like a threading / concurrency issue. Make sure that your code (especially in that static class) is thread-safe.


这篇关于当单元测试用例与其他单元测试用例一起运行时,键入初始化异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆