难以为FitNesse CSlim创建Fixture

时间:2014-09-02 18:02:40

标签: testing automation fitnesse acceptance

我最近开始使用FitNesse,并尝试通过它创建C ++代码的验收测试。我最近下载了CSlim,似乎无法让示例灯具工作。以下是灯具代码的副本:

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "SlimList.h"
#include "Fixtures.h"

class cMultiplication 
{
    public:
    cMultiplication(){};
    ~cMultiplication(){};
    float product()
    {
        return m1*m2;
    }
    float m1;
    float m2;
    char result[32];    
};

#ifndef CPP_COMPILING
extern "C" {
#endif
typedef struct Multiplication
{
    cMultiplication multiplication;
    char result[32];
} Multiplication;

void* Multiplication_Create(StatementExecutor* errorHandler, SlimList* args)
{
    Multiplication* self = (Multiplication*)malloc(sizeof(Multiplication));
    self->result[0] = 0;
     // self->multiplication = new cMultiplication();
    return self;
}

void Multiplication_Destroy(void* void_self)
{
    Multiplication* self = (Multiplication*)void_self;
    // delete self->multiplication;
    free(self);
}

static char* setMultiplicand1(void* void_self, SlimList* args) {
    Multiplication* self = (Multiplication*)void_self;
    self->multiplication.m1 = atof(SlimList_GetStringAt(args, 0));
    return self->result;
}

static char* setMultiplicand2(void* void_self, SlimList* args) {
    Multiplication* self = (Multiplication*)void_self;
    self->multiplication.m2 = atof(SlimList_GetStringAt(args, 0));
    return self->result;
}

static char* Product(void* void_self, SlimList* args) {
    Multiplication* self = (Multiplication*)void_self;
    float product = self->multiplication.product();
    snprintf(self->result, 32, "%g", product);
    return self->result;
}


SLIM_CREATE_FIXTURE(Multiplication) 
    SLIM_FUNCTION(setMultiplicand1)
    SLIM_FUNCTION(setMultiplicand2)
    SLIM_FUNCTION(Product)
SLIM_END

#ifndef CPP_COMPILING
}
#endif  

我愿意为你提供任何帮助和智慧。

<code>!define TEST_SYSTEM {slim}

!path C:\Users\212411176\Documents\Git_Repositories\cslim-master\fixtures\

!define COLLAPSE_SETUP {true}
!define COLLAPSE_TEARDOWN {true}


!|import|
|FixtureInCpp.cpp|

|cMultiplication|
|Multiplication1|Multiplication2|Product?|
|1|1|1|
|5|4|20|
|5|4|20|

提前感谢您提供的任何见解。

干杯,

亚历山大

1 个答案:

答案 0 :(得分:0)

需要更新灯具,尝试按照灯具

!define TEST_SYSTEM {slim} 
!define TEST_RUNNER {PATH_TO_CSlim}
!define COMMAND_PATTERN {%m} 
!define SLIM_VERSION {0.0} 

!|import|
|FixtureInCpp.cpp|

|Multiplication|     | Multiplicand1 | Multiplicand2 |产品?| |1|1|1|     |5|4|20|     |5|4|20|