有没有一个框架可以用来在 Kotlin Compose 项目中自动化 UI 回归测试?单击 Android StudioRun -> Record Expresso Test会出现警告:Espresso Testing Framework does not support Compose projects.
android ui-automation kotlin expresso android-jetpack-compose
有谁知道如何测试Mongoose Validations?
例如,我有以下Schema(作为示例):
var UserAccount = new Schema({
user_name : { type: String, required: true, lowercase: true, trim: true, index: { unique: true }, validate: [ validateEmail, "Email is not a valid email."] },
password : { type: String, required: true },
date_created : { type: Date, required: true, default: Date.now }
});
Run Code Online (Sandbox Code Playgroud)
该validateEmail方法被定义为这样的:
// Email Validator
function validateEmail (val) {
return /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(val);
}
Run Code Online (Sandbox Code Playgroud)
我想测试验证.最终的结果是我希望能够测试验证并根据发生的事情,然后我可以编写其他测试来测试这些代码片段之间的交互.示例:用户尝试使用与所用用户名相同的用户名进行注册(电子邮件已在使用中).我需要一个我可以实际拦截的测试,或者看到验证工作没有达到DB.我不想在这些测试中击中Mongo.这些应该是UNIT测试而不是集成测试.:)
谢谢!
假设我有这个文本输入.
tes{}tR{R{abc}aD{mnoR{xyz}}}
Run Code Online (Sandbox Code Playgroud)
我想提取ff输出:
R{abc}
R{xyz}
D{mnoR{xyz}}
R{R{abc}aD{mnoR{xyz}}}
Run Code Online (Sandbox Code Playgroud)
目前,我只能使用msdn中的平衡组方法提取{}组内的内容.这是模式:
^[^{}]*(((?'Open'{)[^{}]*)+((?'Target-Open'})[^{}]*)+)*(?(Open)(?!))$
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在输出中包含R {}和D {}?
我目前正在努力在实现LoaderManager.LoaderCallbacks的Android ListActivity上实现功能测试.此Activity有一个简单的布局,其中包含一个EditText,供用户输入一些字符串; ListView,它通过Custom CursorAdapter填充,从自定义内容提供程序获取数据,并使用LoadManager自动更新列表视图内容它改变.
此ListActivity的预期功能仅供用户在EditText上输入一些内容并从ListView中选择一个或多个项目.
为了实现这个功能测试,我正在使用Expresso,这里是我的实现:
public class NewWordActivityFunctionalTest extends ActivityInstrumentationTestCase2<NewWordActivity>{
public NewWordActivityFunctionalTest() {
super(NewWordActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
getActivity();
}
public void testFillNewThemeFormAndSubmit() throws InterruptedException {
onView(withId(R.id.submit_new_word_button))
.perform(click());
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行它,我得到的错误堆栈跟踪如下:
com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:579)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:69)
at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:40)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:159)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(ViewInteraction.java:90)
at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewInteraction.java:73)
at pt.consipere.hangman.ui.test.NewWordActivityFunctionalTest.testFillNewThemeFormAndSubmit(NewWordActivityFunctionalTest.java:36)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at …Run Code Online (Sandbox Code Playgroud) 我安装了NodeJS和Mocha并在Windows 7 x64上运行 - 到目前为止,非常好 - 但我不能让Mocha识别使用该exports界面定义的任何测试(如http://visionmedia.github.com/mocha/所述))
如果我创建包含以下代码的test/bdd.js:
var should = require('should');
describe('TestDemo - BDD interface', function(){
describe('#foo', function(){
it('1 should equal 1', function(){ (1).should.equal(1); });
});
});
Run Code Online (Sandbox Code Playgroud)
我可以运行mocha并获得预期的输出:
D:\Projects\NodeDemo>mocha -R spec
TestDemo - BDD interface
#foo
? 1 should equal 1
? 1 tests complete (7ms)
D:\Projects\NodeDemo>
Run Code Online (Sandbox Code Playgroud)
但是如果我创建包含此代码的test/exports.js(基于Mocha站点上提供的'exports'接口示例)
var should = require('should');
module.exports = {
'TestDemo - exports interface': {
'#foo': {
'1 should equal 1': function(){ (1).should.equal(1); }
}
}
};
Run Code Online (Sandbox Code Playgroud)
当我运行Mocha时,它没有找到任何测试:
D:\ Projects\NodeDemo> …
我正在尝试编写Espresso单元测试,该测试依赖于使TCP/IP网络连接到外部应用程序以便成功通过的组件.
测试失败的原因是TCP/IP网络花费的时间比Espresso允许的时间长......
因此,我们需要有TCP/IP代码类TCPConnectionTask实现IdlingResource:
但是,我得到了这个例外:
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:200)
at android.os.Handler.<init>(Handler.java:114)
at android.app.Activity.<init>(Activity.java:786)
at com.sample.QuicksetSampleActivity.<init>(QuicksetSampleActivity.java:82)
at com.unitTests.QuicksetSampleActivityTest.<init>(QuicksetSampleActivityTest.java:52)
Run Code Online (Sandbox Code Playgroud)
我附上TCPConnectionTask并打电话Looper.prepare()和尝试过Looper.prepareMainLooper(),没有成功,见下文(TCPConnectionTask):
/**
* Async task to connect to create TCPIPDataComm and connect to external IRB.
*
*/
public class TCPConnectionTask extends AsyncTask<String, Void, Void > implements IdlingResource {
String ip_user = null;
int port_user;
private ResourceCallback callback;
private boolean flag = false;
protected Void doInBackground(String... args) …Run Code Online (Sandbox Code Playgroud)