????????????
?????ecmadao ???????[ 2016/9/20 14:00:08 ] ??????????????? ???????
?????????????
import React from 'react';
import {expect} from 'chai';
import {shallow} from 'enzyme';
import TestComponent from '../components/TestComponent';
describe('Test TestComponent'?? () => {
// ???????????????
const wrapper = shallow(
<TestComponent num={10} />/
);
/*
* ??????????:
* ???wrapper.state()????????state
* ???wrapper.instance()??????????????????????????
* ???wrapper.find()??????????????
* ???????????wrapper.props()????????props
*/
// ??????????????class
it('should render with currect wrapper'?? () => {
expect(wrapper.is('.test_component')).to.equal(true);
});
// ???????????????state
it('should render with currect state'?? () => {
expect(wrapper.state()).to.deep.equal({
clickNum: 10
});
});
// ????????????
it('should add one'?? () => {
wrapper.instance().handleClick();
expect(wrapper.state()).to.deep.equal({
clickNum: 11
});
});
});
????Test Redux
????redux??????????????????mocha???в???
// ????actions
import * as ACTIONS from '../redux/actions';
describe('test actions'?? () => {
it('should return an action to create a todo'?? () => {
let expectedAction = {
type: ACTIONS.NEW_TODO??
todo: 'this is a new todo'
};
expect(ACTIONS.addNewTodo('this is a new todo')).to.deep.equal(expectedAction);
});
});
// ????reducer
import * as REDUCERS from '../redux/reducers';
import * as ACTIONS from '../redux/actions';
describe('todos'?? () => {
let todos = [];
it('should add a new todo'?? () => {
todos.push({
todo: 'new todo'??
complete: false
});
expect(REDUCERS.todos(todos?? {
type: ACTIONS.NEW_TODO??
todo: 'new todo'
})).to.deep.equal([
{
todo: 'new todo'??
complete: false
}
]);
});
});
// ???????store????
import { createStore?? applyMiddleware?? combineReducers } from 'redux';
import thunk from 'redux-thunk';
import chai from 'chai';
import thunkMiddleware from 'redux-thunk';
import * as REDUCERS from '../redux/reducers';
import defaultState from '../redux/ConstValues';
import * as ACTIONS from '../redux/actions'
const appReducers = combineReducers(REDUCERS);
const AppStore = createStore(appReducers?? defaultState?? applyMiddleware(thunk));
let state = Object.assign({}?? AppStore.getState());
// ?????????????state?仯
const subscribeListener = (result?? done) => {
return AppStore.subscribe(() => {
expect(AppStore.getState()).to.deep.equal(result);
done();
});
};
describe('use store in unittest'?? () => {
it('should create a todo'?? (done) => {
// ?????????????????
state.todos.append({
todo: 'new todo'??
complete: false
});
// ???state????
let unsubscribe = subscribeListener(state?? done);
AppStore.dispatch(ACTIONS.addNewTodo('new todo'));
// ??????????????
unsubscribe();
});
});
???????? phantomjs ??selenium??UI UnitTest
????PhantomJS ?????????webkit?????????JavaScript API??????????????????????????webkit??????????????????????????????????????????????DOM???????????е??????????????UI??????????????????????????????????????????????
?????? Selenium ??????Web??ó????д?????????????????????????????????С? Selenium ??????????????????????棬????????????????????? PhantomJS ???????????????????
????· open ??? url
????· ???? onload ???
????· ?????????? sendEvent ???? api ??????? DOM ??????? point
????· ????????
????· ???? UI ??????? ??? setTimeout ??????????????????????????? sendEvent ???????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
iOS???????mocha??chai??sinon??istanbul???????????????????????????????????????д?????Java????????7??????Android?????????Robolectric3.0????(?)???Kiwi?????????????????????????????????Python?????????????????????????????????????Controller????????д?????????10???????????????????Angular????????????Component??Directive??Pipe ???ServiceAndroid????????????????????????????????--Mockito??????iOS UnitTest???????Vue?????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????