在标题中,我想测试这样的方法:
public void startThread()
{
new Thread()
{
public void run()
{
myLongProcess();
}
}.start();
}
Run Code Online (Sandbox Code Playgroud)
编辑:通过评论判断我认为测试线程是否启动并不常见.所以我要调整问题......如果我的要求是100%的代码覆盖率,我是否需要测试该线程是否启动?如果是这样,我真的需要一个外部框架吗?
我正在尝试使用Visual Studio 2010在Windows 7全新安装的64位计算机上编译一个简单的32位Hello World应用程序.安装Visual Studio后,我还安装了"Windows SDK for Windows 7和.NET Framework 4".我构建了选择"Win32"作为平台的应用程序.它可以在Windows 7上运行,但是如果我在使用Windows XP Professional的32位计算机上运行应用程序(全新安装,没有软件和Service Pack),它似乎无法解决此错误:
"This application has failed to start because msvcr100.dll was not found"
Run Code Online (Sandbox Code Playgroud)
如果它有用,Dependency Walker会检测到2个错误(有关详细信息,请参阅链接图片):
"Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module."
"Error: Modules with different CPU types were found."
Run Code Online (Sandbox Code Playgroud)
http://img820.imageshack.us/img820/4725/errordp.png(Pitect)
我该如何解决?谢谢!
作为示例,请考虑以下bash脚本.有两个循环,第一个循环在后台执行,第二个循环打印myvar值:
#!/bin/bash
myvar=AAA
while true;
do
sleep 3
myvar=BBB
sleep 3
myvar=CCC
done &
while true;
do
echo "${myvar}"
sleep 1
done
Run Code Online (Sandbox Code Playgroud)
我实际获得的输出:
AAA
AAA
AAA
...
Run Code Online (Sandbox Code Playgroud)
我希望获得的输出:
AAA
BBB
CCC
BBB
CCC
...
Run Code Online (Sandbox Code Playgroud) 让我们假设我要测试这个ClassA依赖于难以实例化的Java ClassB:
public class ClassA
{
public ClassA()
{
String configFile = "config_file.xml";
// I have to pass configFile to instantiate ClassB.
// And for example if configFile does not exists in the testing machine?
// Wouldn't it be easier to have an empty constructor for classB to test ClassA?
ClassB classB = new ClassB(configFile);
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
ClassB:
class ClassB
{
ClassB(String configFile)
{
// Set up configs.
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
classB仅仅为了测试目的而在内部创建一个空构造函数是不好的做法吗?或者为此重写一个简化的模拟是否更好 …
您是否注意到(不仅在Vim中)光标在按下移动键后仍然无法均匀地改变位置但是光标不会移动时总是额外的0.5秒?有没有办法防止这种行为在Vim?
我正在学习JUnit,我知道assertEquals()调用equals()方法来比较对象...那么为什么以下测试比较两个正则表达式模式对象不通过?
@Test
public void testTwoCompiledPattern()
{
assertEquals(Pattern.compile("test"), Pattern.compile("test"));
}
Run Code Online (Sandbox Code Playgroud)
这个通过:
@Test
public void testTwoCompiledPattern()
{
assertEquals(Pattern.compile("test").toString(), Pattern.compile("test").toString());
}
Run Code Online (Sandbox Code Playgroud) 正如标题一样,为什么 lsmod 没有列出 Xorg 默认加载的 extmod、dri、dbe 等模块?
java ×3
junit ×3
testing ×3
unit-testing ×3
32bit-64bit ×1
bash ×1
c ×1
kernel ×1
linux ×1
linux-kernel ×1
mocking ×1
module ×1
regex ×1
scripting ×1
shell ×1
text-editor ×1
unix ×1
vim ×1
x11 ×1
xorg ×1