Commit 69943f80 by xiaojing.zhang

测试代码独立于开发代码

parent d964b52f
...@@ -13,7 +13,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets ...@@ -13,7 +13,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 CONFIG += c++11
DEFINES += FM_DEBUG #DEFINES += FM_DEBUG
SOURCES += \ SOURCES += \
fmp_vip.cpp \ fmp_vip.cpp \
......
...@@ -17,27 +17,31 @@ ...@@ -17,27 +17,31 @@
//#define PARTNER_ID "df2f90b0-eece-402c-820d-ba8ac56c4687" //#define PARTNER_ID "df2f90b0-eece-402c-820d-ba8ac56c4687"
//! 加移 //! 加移
#define APP_ID "T019" //#define APP_ID "T019"
#define KEY_CODE "059e15e7-19a6-480f-8b5f-3a082a5b553e" //#define KEY_CODE "059e15e7-19a6-480f-8b5f-3a082a5b553e"
#define PARTNER_ID "c3e82ff2-6285-4823-8e3f-7ec880ae7119" //#define PARTNER_ID "c3e82ff2-6285-4823-8e3f-7ec880ae7119"
//! 测试
#define APP_ID "T015"
#define KEY_CODE "85870ccc8da9affa5eafe7488533f273"
#define PARTNER_ID "7f657d18-9f3f-41fd-b97f-1a71f7d1ffa0"
// 请求类型的枚举值 // 请求类型的枚举值
enum FM_TYPE { enum FM_TYPE {
FM_Set_Store_Info = 1000, FM_Set_Store_Info = 1000,//门店信息
FM_Login = 1001, FM_Login = 1001, //会员信息查询
FM_Fund = 1002, FM_Fund = 1002, //会员充值
FM_Pay = 1003, FM_Pay = 1003, //会员支付
FM_Refund = 1004, FM_Refund = 1004, //会员退款
FM_Final = 1007, FM_Final = 1007, //会员结算
FM_Coupon = 1009, FM_Coupon = 1009,
FM_Order_Revoke, FM_Order_Revoke,
FM_QR_QUERY = 10030, FM_QR_QUERY = 10030,
FM_QR_Pay = 10031, FM_QR_Pay = 10031,
FM_Coupon_Pay, FM_Coupon_Pay,
FM_QR_Refund = 10041, FM_QR_Refund = 10041,
FM_Refund_Pay, FM_Refund_Pay, //超时退款
FM_Refund_Order FM_Refund_Order //订单退款
}; };
enum Member_Type { enum Member_Type {
......
...@@ -839,12 +839,6 @@ font: 13px "微软雅黑"; ...@@ -839,12 +839,6 @@ font: 13px "微软雅黑";
<height>47</height> <height>47</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>0</string> <string>0</string>
</property> </property>
...@@ -857,14 +851,8 @@ font: 13px &quot;微软雅黑&quot;; ...@@ -857,14 +851,8 @@ font: 13px &quot;微软雅黑&quot;;
<widget class="QPushButton" name="score_key"> <widget class="QPushButton" name="score_key">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>40</width>
<height>0</height> <height>47</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size> </size>
</property> </property>
<property name="cursor"> <property name="cursor">
...@@ -894,8 +882,8 @@ font: 13px &quot;微软雅黑&quot;; ...@@ -894,8 +882,8 @@ font: 13px &quot;微软雅黑&quot;;
<widget class="QLabel" name="score_label"> <widget class="QLabel" name="score_label">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>0</width> <width>16777215</width>
<height>0</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
......
include(../../fmvip/fmvip.pri) include(../../fmvip/fmvip.pri)
include(gtest_dependency.pri)
include ("../../../FreemudPOS/qtservice/src/qtservice.pri")
QT += testlib sql QT += testlib sql network core gui
CONFIG += C++11 CONFIG += C++11
DEFINES += FMTEST FM_DEBUG #DEFINES += UNIT_TEST
CONFIG += qt console warn_on depend_includepath testcase CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle CONFIG -= app_bundle
TEMPLATE = app TEMPLATE = app
SOURCES += tst_testplugin.cpp SOURCES += readjsoncommand.cpp \
main.cpp
CONFIG(debug, debug|release) { CONFIG(debug, debug|release) {
LIBS += -lCTKCored -lCTKPluginFrameworkd LIBS += -lCTKCored -lCTKPluginFrameworkd
...@@ -20,3 +24,9 @@ CONFIG(debug, debug|release) { ...@@ -20,3 +24,9 @@ CONFIG(debug, debug|release) {
LIBS += -lCTKCore -lCTKPluginFramework LIBS += -lCTKCore -lCTKPluginFramework
DESTDIR = $$PWD/../../../release/bins DESTDIR = $$PWD/../../../release/bins
} }
HEADERS += \
readjsoncommand.h \
test_newvip.h \
../../../include/application/fm_singleton.h
isEmpty(GOOGLETEST_DIR):GOOGLETEST_DIR=$$(GOOGLETEST_DIR)
isEmpty(GOOGLETEST_DIR) {
warning("Using googletest src dir specified at Qt Creator wizard")
message("set GOOGLETEST_DIR as environment variable or qmake variable to get rid of this message")
GOOGLETEST_DIR = E:/Code/googletest
}
!isEmpty(GOOGLETEST_DIR): {
GTEST_SRCDIR = $$GOOGLETEST_DIR/googletest
GMOCK_SRCDIR = $$GOOGLETEST_DIR/googlemock
}
requires(exists($$GTEST_SRCDIR):exists($$GMOCK_SRCDIR))
!exists($$GOOGLETEST_DIR):message("No googletest src dir found - set GOOGLETEST_DIR to enable.")
INCLUDEPATH *= \
$$GTEST_SRCDIR \
$$GTEST_SRCDIR/include \
$$GMOCK_SRCDIR \
$$GMOCK_SRCDIR/include
SOURCES += \
$$GTEST_SRCDIR/src/gtest-all.cc \
$$GMOCK_SRCDIR/src/gmock-all.cc
#include <gtest/gtest.h>
#include "readjsoncommand.h"
#include "test_newvip.h"
extern FooEnvironment* foo_env; //对象指针声明
int main(int argc, char *argv[])
{
QApplication a(argc,argv);
foo_env = new FooEnvironment;
testing::AddGlobalTestEnvironment(foo_env); //注册
testing::GTEST_FLAG(output) = "xml:TestReport.xml";
::testing::InitGoogleTest(&argc, argv);
RUN_ALL_TESTS();
}
#include "readjsoncommand.h"
#include <QFile>
#include <QDebug>
#include <QDir>
#include <QApplication>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
#include <QDateTime>
#include <QEventLoop>
#include <QNetworkAccessManager>
#include <QUrl>
#include <QNetworkReply>
#include <QNetworkRequest>
ReadJsonCommand::ReadJsonCommand()
{
qDebug()<<"Test";
}
QString ReadJsonCommand::Readjson(QString fileName)
{
bool ret;
QFile file;
QString val;
QString exePath;
QString jsonPath;
exePath= qApp->applicationDirPath();;
jsonPath= exePath.left(exePath.length()-4);
jsonPath.append("json/").append(fileName);
file.setFileName(jsonPath);
ret= file.open(QIODevice::ReadOnly | QIODevice::Text);
if(ret)
{
val = file.readAll();
}
else
{
qDebug()<<file.error();
val = file.errorString();
}
file.close();
return val;
}
QByteArray ReadJsonCommand::modifyTranID(QByteArray reqData)
{
QJsonParseError error;
QJsonObject jsonObj;
QJsonDocument doc = QJsonDocument::fromJson(reqData, &error);
if(error.error == QJsonParseError::NoError)
{
jsonObj = doc.object();
jsonObj["order_id"] = QDateTime::currentDateTime().toString("yyMMddhhmmsszzz");
jsonObj["trans_id"] = QDateTime::currentDateTime().toString("MMddhhmmsszzz");
order_id = QDateTime::currentDateTime().toString("yyMMddhhmmsszzz");
}
QJsonDocument json(jsonObj);
QByteArray Modifydata = json.toJson(QJsonDocument::Compact);
qDebug()<<"Test value"<<Modifydata;
return Modifydata;
}
QByteArray ReadJsonCommand::modifyRefundPara(QByteArray reqData)
{
QJsonParseError error;
QJsonObject jsonObj;
QJsonDocument doc = QJsonDocument::fromJson(reqData, &error);
if(error.error == QJsonParseError::NoError)
{
jsonObj = doc.object();
jsonObj["order_id"] = order_id;
}
QJsonDocument json(jsonObj);
QByteArray Modifydata = json.toJson(QJsonDocument::Compact);
qDebug()<<"Test value"<<Modifydata;
return Modifydata;
}
QString ReadJsonCommand::GetTranID()
{
return trans_id;
}
//key未嵌套解析
QString ReadJsonCommand::JsonValue(QByteArray parseData,QString key)
{
QJsonParseError error;
QString amount;
QJsonDocument rspJson = QJsonDocument::fromJson(parseData, &error);
if(error.error == QJsonParseError::NoError) {
if(rspJson.isObject())
{
QVariantMap result = rspJson.toVariant().toMap();
amount = result[key].toString();
}
}
else
{
qDebug()<<error.errorString();
}
return amount;
}
QString ReadJsonCommand::ParseSecondLevel(QByteArray parseData,QString first,QString key)
{
QJsonParseError error;
QString amount;
QJsonDocument rspJson = QJsonDocument::fromJson(parseData, &error);
if(error.error == QJsonParseError::NoError) {
if(rspJson.isObject())
{
QVariantMap result = rspJson.toVariant().toMap();
QVariantMap nestedMap = result[first].toMap();
amount = nestedMap[key].toString();
}
}
else
{
qDebug()<<error.errorString();
}
return amount;
}
//将付款码存入文件
void ReadJsonCommand::SavePayCode(QString payCode)
{
QString fileName = qApp->applicationDirPath()+ "/"+"paycode.txt";
qDebug()<<"....................."<<fileName;
QFile file(fileName);
if(!file.open(QIODevice::ReadWrite|QIODevice::Text))
{
qDebug()<<"open file faild !";
}
QTextStream in(&file);
in<<payCode;
in.flush();
file.close();
}
//获取付款码
QString ReadJsonCommand::GetPayCode()
{
QNetworkAccessManager networkAcessManager;
QNetworkRequest _req;
QString codeFormat;
QString url = "http://membertest1.sandload.cn:8748/wechat/card/getPayCode?partnerId=7f657d18-9f3f-41fd-b97f-1a71f7d1ffa0&openId=o4_93jjwHWPke-U1IT2IkUO5hbII&mobile=15821343897&URL=http%3A%2F%2Fjtest.sandload.cn";
_req.setUrl(url);
auto reply = networkAcessManager.get(_req);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QByteArray rspData= reply->readAll();
qDebug()<<"reply get "<<rspData;
QJsonParseError jsonErr;
QJsonDocument rspJson = QJsonDocument::fromJson(rspData, &jsonErr);
if(jsonErr.error == QJsonParseError::NoError) {
if(rspJson.isObject())
{
QVariantMap result = rspJson.toVariant().toMap();
QVariantMap nestedMap = result["data"].toMap();
codeFormat = nestedMap["codeFormat"].toString();
codeFormat.remove(QRegExp("\\s"));
qDebug() << "length:" << codeFormat;
}
}
qDebug()<<"..........................."<<codeFormat;
SavePayCode(codeFormat);
return codeFormat;
}
#ifndef READJSONCOMMAND_H
#define READJSONCOMMAND_H
#include<QString>
class ReadJsonCommand
{
public:
ReadJsonCommand();
QString Readjson(QString fileName);
QByteArray modifyTranID(QByteArray reqData); //保证测试时交易ID不重复
QByteArray modifyRefundPara(QByteArray reqData);
QString GetTranID();
QString JsonValue(QByteArray parseData,QString key);
QString ParseSecondLevel(QByteArray parseData,QString first,QString key);
QString GetPayCode();
void SavePayCode(QString payCode);
private:
QString trans_id; //记录交易ID供退款使用
QString order_id;
};
#endif // READJSONCOMMAND_H
#ifndef TEST_NEWVIP
#define TEST_NEWVIP
#endif // TEST_NEWVIP
#include "fmvipdispatcher.h"
#include "fmtask.h"
#include "fmnumpad.h"
#include "readjsoncommand.h"
#include "fmp_settings_i.h"
#include "fmp_manager_i.h"
#include "fmp_base_i.h"
#include <ctkPluginFrameworkFactory.h>
#include <ctkPluginFramework.h>
#include <ctkPluginException.h>
#include <QByteArray>
#include <gtest/gtest.h>
#include <QString>
#include <QSettings>
#include <QtGui>
#include <QtCore>
#include <qtservice.h>
#include <QTest>
class FooEnvironment: public testing::Environment
{
public:
virtual void SetUp()
{
//独立加载set模块
QSettings *_setting = new QSettings(qApp->applicationDirPath()+ "/"+"FreemudPOS.ini", QSettings::IniFormat);
QString _plugin_path = _setting->value(FMP_INIKEY_PLUGINPATH, "plugins").toString();
QString _entry_plugin = _setting->value(FMP_INIKEY_ENTRYSERVICE, "com.fmp.home").toString();
FMPProps props;
props[FMP_PROPKEY_PLUGINPATH] = _plugin_path;
props[FMP_PROPKEY_ENTRY] = _entry_plugin;
props[FMP_PROPKEY_CFG] = _setting->fileName();
QString dir = "D:/newTest/debug/plugins/fmp_settings_0.1.0.dll";
QUrl url = QUrl::fromLocalFile(dir);
QSharedPointer<ctkPlugin> plugin;
ctkPluginContext *_ctx;
ctkPluginFrameworkFactory *_fw_factory = new ctkPluginFrameworkFactory(props);
QSharedPointer<ctkPluginFramework> _fw = _fw_factory->getFramework();
_fw->init();
_ctx = _fw->getPluginContext();
_fw->start(ctkPlugin::START_TRANSIENT);
plugin =_ctx->installPlugin(url);
plugin->start(ctkPlugin::START_TRANSIENT);
FMPSettingsInterface *svc;
ctkServiceReference ref = _ctx->getServiceReference<FMPSettingsInterface>();
if (ref) {
svc = _ctx->getService<FMPSettingsInterface>(ref);
}
// FMPSettingsInterface *settingInter = GetService<FMPSettingsInterface>(_ctx);
FMPVipSettings::instance()->init(svc);
printf("Environment SetUp!\n");
}
virtual void TearDown()
{
printf("Environment TearDown!\n");
}
ReadJsonCommand readjson;
FMVipDispatcher fmvip;
int AmountBefore;
int AmountAfter;
int VIPMount;//会员卡剩余金额
int VIPScore; //会员积分
};
FooEnvironment* foo_env;
void DeleteLocalDB()
{
QString path = qApp->applicationDirPath();
path = path+'/'+"FreemudPOS.db";
QFile file(path);
if (file.exists())
{
file.remove();
}
}
bool respDataDetect(QByteArray rspData)
{
QString strRspData;
strRspData = rspData;
return strRspData.contains("\"status_code\":100", Qt::CaseInsensitive); // returns true
}
QByteArray storeInfo()
{
QByteArray reqData;
QByteArray rspData;
QString ret;
ret = foo_env->readjson.Readjson("set_storaInfo.json");
reqData = ret.toLocal8Bit();
foo_env->fmvip.doTask(reqData,rspData);
return rspData;
}
QByteArray VipInfo()
{
bool ok;
QByteArray reqData;
QByteArray rspData;
QString ret;
ret = foo_env->readjson.Readjson("set_vipConfirm.json");
reqData = ret.toLocal8Bit();
foo_env->fmvip.doTask(reqData,rspData);
QString mount =foo_env->readjson.ParseSecondLevel(rspData,"data","amount");
QString score = foo_env->readjson.ParseSecondLevel(rspData,"data","score");
foo_env->VIPMount =mount.toInt(&ok, 10);
foo_env->VIPScore =score.toInt(&ok, 10);
return rspData;
}
QByteArray VipPay()
{
QByteArray reqData;
QByteArray rspData;
QString ret;
ret = foo_env->readjson.Readjson("set_pay.json");
reqData = ret.toLocal8Bit();
reqData =foo_env->readjson.modifyTranID(reqData);
foo_env->fmvip.doTask(reqData,rspData);
return rspData;
}
QByteArray VipOrder()
{
QByteArray reqData;
QByteArray rspData;
QString ret;
ret = foo_env->readjson.Readjson("set_order.json");
reqData = ret.toLocal8Bit();
reqData = foo_env->readjson.modifyRefundPara(reqData);
foo_env->fmvip.doTask(reqData,rspData);
return rspData;
}
QByteArray VipRefund()
{
QByteArray reqData;
QByteArray rspData;
QString ret;
ret = foo_env->readjson.Readjson("set_refund.json");
reqData = ret.toLocal8Bit();
reqData = foo_env->readjson.modifyRefundPara(reqData);
foo_env->fmvip.doTask(reqData,rspData);
return rspData;
}
////////////////////////////////////////////////////////////////////////
//
TEST(TestNewVip, Vip_InfoFailed)
{
DeleteLocalDB();
QByteArray rspData;
rspData = VipInfo();
ASSERT_FALSE(respDataDetect(rspData));
}
//设置门店信息
TEST(TestNewVip, store_Info)
{
QByteArray rspData;
rspData = storeInfo();
ASSERT_TRUE(respDataDetect(rspData));
}
//获取VIP信息,认证成功
TEST(TestNewVip, Vip_InfoSuccess)
{
QByteArray rspData;
rspData = VipInfo();
ASSERT_TRUE(respDataDetect(rspData));
}
//付款
TEST(TestNewVip, Vip_Pay)
{
foo_env->readjson.GetPayCode();
QByteArray rspData;
rspData = VipPay();
QString temp = foo_env->readjson.JsonValue(rspData,"paid_amount");
bool ok;
foo_env->AmountBefore = temp.toInt(&ok, 10);
ASSERT_TRUE(respDataDetect(rspData));
}
//支付退款
TEST(TestNewVip, Vip_RefundPay)
{
QByteArray rspData;
rspData = VipRefund();
QString temp = foo_env->readjson.JsonValue(rspData,"refund_amount");
bool ok;
foo_env->AmountAfter = temp.toInt(&ok, 10);
ASSERT_TRUE(respDataDetect(rspData));
}
//金额核对付款后
TEST(TestNewVip,CheckAfterPay)
{
int j = foo_env->AmountAfter-foo_env->AmountBefore;
ASSERT_FALSE(j);
}
//付款
TEST(TestNewVip, Vip_RePay)
{
QByteArray rspData;
rspData = VipPay();
ASSERT_TRUE(respDataDetect(rspData));
}
//订单结算
TEST(TestNewVip, Vip_Order)
{
QByteArray rspData;
rspData = VipOrder();
qDebug()<< "order jiesuan";
ASSERT_TRUE(respDataDetect(rspData));
}
//订单退款
TEST(TestNewVip, Vip_RefundOrder)
{
QByteArray rspData;
rspData = VipRefund();
ASSERT_TRUE(respDataDetect(rspData));
}
//金额核对在订单退款后
TEST(TestNewVip,CheckAfterRefindPay)
{
int tempMount = foo_env->VIPMount;
int tempScore = foo_env->VIPScore;
QByteArray rspData;
rspData = VipInfo();
ASSERT_FALSE(foo_env->VIPMount-tempMount);
ASSERT_FALSE(foo_env->VIPScore-tempScore);
}
/*
//金额核对在重新支付后
TEST(TestNewVip,CheckAfterRePay)
{
}
//金额核对在结算后
TEST(TestNewVip,CheckAfterOrder)
{
}
//金额核算在结算退款后
TEST(TestNewVip,CheckAfterReFundOrder)
{
}
*/
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QMessageBox> #include <QMessageBox>
#include "fmvipdispatcher.h" #include "fmvipdispatcher.h"
#include "fmtask.h" #include "fmtask.h"
#include "fmnumpad.h" #include "fmnumpad.h"
#include "readjsoncommand.h"
class TestPlugin : public QObject class TestPlugin : public QObject
{ {
...@@ -48,6 +50,7 @@ TestPlugin::~TestPlugin() ...@@ -48,6 +50,7 @@ TestPlugin::~TestPlugin()
void TestPlugin::initTestCase() void TestPlugin::initTestCase()
{ {
} }
void TestPlugin::cleanupTestCase() void TestPlugin::cleanupTestCase()
...@@ -59,38 +62,38 @@ void TestPlugin::test_dotask_data() ...@@ -59,38 +62,38 @@ void TestPlugin::test_dotask_data()
{ {
QTest::addColumn<QByteArray>("reqData"); QTest::addColumn<QByteArray>("reqData");
QTest::newRow("Refund") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"20171018003\"}"); //QTest::newRow("Refund") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"20171018003\"}");
QTest::newRow("Refund not") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"12345\"}"); //QTest::newRow("Refund not") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"12345\"}");
QTest::newRow("SetStoreInfo") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"99999\",\"pos_id\": \"1\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}"); //QTest::newRow("SetStoreInfo") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"99999\",\"pos_id\": \"1\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("SetStoreInfo_need_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": \"\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}"); // QTest::newRow("SetStoreInfo_need_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": \"\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("SetStoreInfo_notnull_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}"); // QTest::newRow("SetStoreInfo_notnull_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("SetStoreInfo_error_type") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": 1,\"business_date\": \"20171016\",\"operator_id\": \"001\"}"); // QTest::newRow("SetStoreInfo_error_type") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": 1,\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("Login") << QByteArray("{\"fm_cmd\": 1001}"); QTest::newRow("Login") << QByteArray("{\"fm_cmd\": 1001}");
QTest::newRow("Pay") << QByteArray("{" // QTest::newRow("Pay") << QByteArray("{"
" \"fm_cmd\": 1003," // " \"fm_cmd\": 1003,"
" \"order_amount\":900," // " \"order_amount\":900,"
" \"trans_amount\": 800," // " \"trans_amount\": 800,"
" \"undis_amount\": 800," // " \"undis_amount\": 800,"
" \"order_id\": \"20171018003\"," // " \"order_id\": \"20171018003\","
" \"trans_id\": \"100001\"," // " \"trans_id\": \"100001\","
" \"products\": [" // " \"products\": ["
" {" // " {"
" \"pid\": \"0079020\"," // " \"pid\": \"0079020\","
" \"name\": \"测试商品1\"," // " \"name\": \"测试商品1\","
" \"price\": 100," // " \"price\": 100,"
" \"consume_num\": 1" // " \"consume_num\": 1"
" }," // " },"
" { " // " { "
" \"pid\": \"0077842\"," // " \"pid\": \"0077842\","
" \"name\": \"测试商品2\"," // " \"name\": \"测试商品2\","
" \"price\": 800," // " \"price\": 800,"
" \"consume_num\": 2" // " \"consume_num\": 2"
" }" // " }"
" ]" // " ]"
"}"); // "}");
QTest::newRow("Order") << QByteArray("{\"fm_cmd\": 1007,\"order_id\": \"20171018003\"}"); // QTest::newRow("Order") << QByteArray("{\"fm_cmd\": 1007,\"order_id\": \"20171018003\"}");
QTest::newRow("Fund") << QByteArray("{\"fm_cmd\": 1002,\"order_id\": \"20171018001\"}"); // QTest::newRow("Fund") << QByteArray("{\"fm_cmd\": 1002,\"order_id\": \"20171018001\"}");
QTest::newRow("CouponPay") << QByteArray("{\"fm_cmd\": 10032}"); // QTest::newRow("CouponPay") << QByteArray("{\"fm_cmd\": 10032}");
} }
void TestPlugin::test_dotask() void TestPlugin::test_dotask()
......
#-------------------------------------------------
#
# Project created by QtCreator 2018-05-03T09:57:19
#
#-------------------------------------------------
QT += testlib
QT -= gui
TARGET = tst_tst_testvipplugintest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
tst_tst_testvipplugintest.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
#include <QString>
#include <QtTest>
#include <QCoreApplication>
class Tst_testVipPluginTest : public QObject
{
Q_OBJECT
public:
Tst_testVipPluginTest();
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void testCase1_data();
void testCase1();
};
Tst_testVipPluginTest::Tst_testVipPluginTest()
{
}
void Tst_testVipPluginTest::initTestCase()
{
}
void Tst_testVipPluginTest::cleanupTestCase()
{
}
void Tst_testVipPluginTest::testCase1_data()
{
QTest::addColumn<QString>("data");
QTest::newRow("0") << QString();
}
void Tst_testVipPluginTest::testCase1()
{
QFETCH(QString, data);
QVERIFY2(true, "Failure");
}
QTEST_MAIN(Tst_testVipPluginTest)
#include "tst_tst_testvipplugintest.moc"
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 36 #define VER_BUILD 38
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment