我知道这个问题非常普遍,但我没有找到任何关于为什么会出现此错误的提示.在Eclipse窗口中看到initalizationError的可能原因是什么?我没有获得有用的信息只是一个漫长而无用的故障跟踪(此处未包括在内).
我正在使用JUnit 4.11
我写了以下代码 - 只是为了看它是否有效:
package test;
import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class SimpleTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Test
public void test() {
assertEquals(15, 15);
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:对不起在Eclipse窗口中,它实际上称为"失败跟踪":
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing at
java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClass(Unknown Source) at
java.security.SecureClassLoader.defineClass(Unknown Source) at
java.net.URLClassLoader.defineClass(Unknown Source) at
java.net.URLClassLoader.access$100(Unknown Source) at
java.net.URLClassLoader$1.run(Unknown Source) at
java.net.URLClassLoader$1.run(Unknown Source) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(Unknown …Run Code Online (Sandbox Code Playgroud) 假设我有一个脚本:
write-host "Message.Status: Test Message Status";
Run Code Online (Sandbox Code Playgroud)
我设法通过执行以下操作在单独的进程中运行它:
powershell.exe -Command
{ write-host "Message.Status: Test Message Status"; }
Run Code Online (Sandbox Code Playgroud)
问题是我想将参数传递给脚本,以便我可以实现如下目标:
write-host "I am in main process"
powershell.exe -Command -ArgumentList "I","am","here"
{
write-host "I am in another process"
write-host "Message.Status: $($one) $($two) $($three)";
}
Run Code Online (Sandbox Code Playgroud)
但是-ArgumentList在这里不起作用
我得到:
powershell.exe : -ArgumentList : The term '-ArgumentList' is not recognized as the name of a cmdlet, function, script file, or operable
Run Code Online (Sandbox Code Playgroud)
我需要在不同的进程中运行 PowerShell 脚本文件的某些部分,并且由于 PowerShell 脚本已上传到外部系统,因此我无法使用另一个文件。
我正在用NUnit和Entity Framework编写一些UnitTests.如何从Entity Framework级别删除整个localdb数据库?
注意:我不想清除表的数据.我想删除整个数据库.
此外,我可以在我的应用程序工作目录中创建一个localdb文件,前提是尚未创建数据库:
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "");
var testDbFileName = String.Format(@"UnitTestDB.mdf");
var testDbFileNameWithPath = path + @"\" + testDbFileName;
var connectionString =
String.Format(
@"Data Source=(localdb)\V11.0;Initial Catalog={0};Integrated Security=True;AttachDBFilename={1};MultipleActiveResultSets=True",
"UnitTestDB", testDbFileNameWithPath);
//Here would be the code passing connection string to DbContext and so on..
Run Code Online (Sandbox Code Playgroud)
仅删除文件"UnitTestDB.mdf"是不够的.在SQL Management Studio中仍然有对db的引用
我发现的大多数示例都显示了在xml中设置默认值的方法.我需要在代码隐藏中设置默认值.
注意:值
Environment.getExternalStorageDirectory().getPath() + "/BasicCommunicationWithAndroid.log"
Run Code Online (Sandbox Code Playgroud)
是/storage/sdcard0/BasicCommunicationWithAndroid.log所以它不是null也不是空字符串
public class SettingsFragment extends PreferenceFragment
{
private Preference _pref_log_logFilenameOnSDCard;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
loadPreferences();
}
private void loadPreferences()
{
_pref_log_logFilenameOnSDCard = (Preference) findPreference("pref_log_logFilenameOnSDCard");
_pref_log_logFilenameOnSDCard.setDefaultValue(Environment.getExternalStorageDirectory().getPath() + "/BasicCommunicationWithAndroid.log");
}
}
Run Code Online (Sandbox Code Playgroud)
在onCreate(..)的MainActivity中我有:
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
Run Code Online (Sandbox Code Playgroud) android ×1
code-first ×1
eclipse ×1
java ×1
junit ×1
localdb ×1
powershell ×1
process ×1
windows ×1