简体   繁体   English

在FitNesse中,是否可以在Java和FitSharp测试页之间共享变量或数据?

[英]In FitNesse is it possible to share variables or data between Java and FitSharp test pages?

I've got what I assume is a fairly common scenario: I want to test a web service via FitNesse while also being able to inject and read data from the database behind the web service. 我假设有一个相当普遍的场景:我想通过FitNesse测试一个Web服务,同时还能够从Web服务背后的数据库中插入和读取数据。 For example, I'd like to do the following: 例如,我要执行以下操作:

1) Save a record directly to the database; 1)将记录直接保存到数据库中; then 然后

2) Use the web service to update the record that was created; 2)使用Web服务更新已创建的记录; then 然后

3) Check the database record to see it has been updated correctly. 3)检查数据库记录以查看它是否已正确更新。

The potential fly in the ointment is that the database is SQL Server and I'm developing against my (localdb) instance of SQL Server on my local machine. 美中不足的是,数据库是SQL Server,我正在针对本地计算机上的SQL Server实例(localdb)进行开发。 So I need FitNesse to be able to connect to (localdb). 因此,我需要FitNesse才能连接到(localdb)。

As far as I can see RestFixture, for testing a web service, only runs in the Java version of FitNesse. 据我所知,用于测试Web服务的RestFixture仅在FitNesse的Java版本中运行。 However, the Java version of DbFit, for connecting to databases, can only use Microsoft's JDBC driver for connecting to SQL Server. 但是,用于连接数据库的Java版本的DbFit只能使用Microsoft的JDBC驱动程序来连接到SQL Server。 According to this Stackoverflow question the MS JDBC driver does not support named pipes so cannot connect to (localdb). 根据此Stackoverflow问题 ,MS JDBC驱动程序不支持命名管道,因此无法连接到(localdb)。 Therefore I would have to use the FitSharp (.NET) version of DbFit, which works fine with (localdb). 因此,我将不得不使用FitSharp(.NET)版本的DbFit,该版本可与(localdb)正常工作。

Now the problem is combining Java RestFixture with FitSharp DbFit. 现在的问题是将Java RestFixture与FitSharp DbFit结合使用。 For example, if I create a new record in the database via DbFit I want to read back the identity value of the record I've just created and use that value to identify the record to update via the web service. 例如,如果我通过DbFit在数据库中创建了一条新记录,我想读回刚创建的记录的标识值,并使用该值来标识要通过Web服务更新的记录。 So I would need to pass a variable or some information from the FitSharp DbFit test page to the Java RestFixture test page. 因此,我需要将变量或一些信息从FitSharp DbFit测试页传递到Java RestFixture测试页。 Is this possible? 这可能吗?

As far as I'm aware it is not. 据我所知不是。 The REST API does not support create and read? REST API不支持创建和读取吗? That would allow the entire test via REST (no direct database access required, and no need to run on same server as database). 这样就可以通过REST进行整个测试(无需直接访问数据库,也不需要在与数据库相同的服务器上运行)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM